10 rem word wrap - commodore basic 20 rem rosetta code 30 s$="":co=40:gosub 200 35 print chr$(147);chr$(14) 40 print "The current string is:" 41 print chr$(18);s$;chr$(146) 42 print:print "Enter a string, blank to keep previous," 43 print "or type 'sample' to use a preset"len(z$)" character string." 44 print:input s$:if s$="sample" then s$=z$ 45 print:print "enter column limit, 10-80 [";co;"{left}]";:input co 46 if co<12 or co>80 then goto 45 50 print chr$(147);"Wrapping on column";co;"results as:" 55 gosub 400 60 print 65 print r$ 70 print 80 input "Again (y/n)";yn$ 90 if yn$="y" then goto 35 100 end 200 rem set up sample string 205 data "Lorem Ipsum is typically a corrupted version of 'De finibus " 210 data "bonorum et malorum', a first-century BC text by the Roman statesman " 215 data "and philosopher Cicero, with words altered, added, and removed to " 220 data "make it nonsensical, improper Latin." 225 data "zzz" 230 z$="" 235 read tp$:if tp$<>"zzz" then z$=z$+tp$:goto 235 240 return 400 rem word-wrap string 401 tp$=s$:as$="" 405 if len(tp$)<=co then goto 440 410 for i=0 to co-1:c$=mid$(tp$,co-i,1) 420 if c$<>" " and c$<>"-" then next i 425 ad$=chr$(13):if c$="-" then ad$="-"+chr$(13) 430 as$=as$+left$(tp$,co-1-i)+ad$:tp$=mid$(tp$,co-i+1,len(tp$)):i=0 435 goto 405 440 as$=as$+tp$ 450 r$=as$ 460 return