Word wrap: Difference between revisions
Commodore BASIC - Decided to use sample text from Wikipedia, and improved the initialization of the sample string. Added support for hyphenated words to be broken during wrap.
(Added Commodore BASIC) |
(Commodore BASIC - Decided to use sample text from Wikipedia, and improved the initialization of the sample string. Added support for hyphenated words to be broken during wrap.) |
||
Line 1,066:
100 end
200 rem set up sample string
205
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
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
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$
Line 1,085 ⟶ 1,089:
<pre>Wrapping on column 40 results as:
Lorem Ipsum is
version of 'De finibus bonorum et
malorum', a first-century BC text by
the Roman statesman and philosopher
Cicero, with words altered, added, and
removed to make it nonsensical,
Again (y/n)? y
Line 1,101 ⟶ 1,105:
Wrapping on column 20 results as:
Lorem Ipsum is
Again (y/n)? n
ready.
|