Word wrap: Difference between revisions

Content added Content deleted
(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: Line 1,066:
100 end
100 end
200 rem set up sample string
200 rem set up sample string
205 z$="Lorem Ipsum is simply dummy text of the printing and typesetting "
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 "
210 z$=z$+"industry. Lorem Ipsum has been the industry's standard dummy "
215 data "and philosopher Cicero, with words altered, added, and removed to "
215 z$=z$+"text ever since the 1500s, when an unknown printer took a galley "
220 data "make it nonsensical, improper Latin."
220 z$=z$+"of type and scrambled it to make a type specimen book."
225 return
225 data "zzz"
230 z$=""
235 read tp$:if tp$<>"zzz" then z$=z$+tp$:goto 235
240 return
400 rem word-wrap string
400 rem word-wrap string
401 tp$=s$:as$=""
401 tp$=s$:as$=""
405 if len(tp$)<=co then goto 440
405 if len(tp$)<=co then goto 440
410 for i=0 to co-1:c$=mid$(tp$,co-i,1)
410 for i=0 to co-1:c$=mid$(tp$,co-i,1)
420 if c$<>" " then next i
420 if c$<>" " and c$<>"-" then next i
430 as$=as$+left$(tp$,co-1-i)+chr$(13):tp$=mid$(tp$,co-i+1,len(tp$)):i=0
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
435 goto 405
440 as$=as$+tp$
440 as$=as$+tp$
Line 1,085: Line 1,089:


<pre>Wrapping on column 40 results as:
<pre>Wrapping on column 40 results as:
Lorem Ipsum is simply dummy text of the
Lorem Ipsum is typically a corrupted
version of 'De finibus bonorum et
printing and typesetting industry.
malorum', a first-century BC text by
Lorem Ipsum has been the industry's
the Roman statesman and philosopher
standard dummy text ever since the
Cicero, with words altered, added, and
1500s, when an unknown printer took a
removed to make it nonsensical,
galley of type and scrambled it to make
a type specimen book.
improper Latin.
Again (y/n)? y
Again (y/n)? y




Line 1,101: Line 1,105:


Wrapping on column 20 results as:
Wrapping on column 20 results as:
Lorem Ipsum is
Lorem Ipsum is
simply dummy text
typically a
of the printing and
corrupted version
typesetting
of 'De finibus
industry. Lorem
bonorum et
Ipsum has been the
malorum', a first-
industry's standard
century BC text by
dummy text ever
the Roman statesman
since the 1500s,
and philosopher
when an unknown
Cicero, with words
printer took a
altered, added, and
galley of type and
removed to make it
scrambled it to
nonsensical,
make a type
improper Latin.
specimen book.
Again (y/n)? n
Again (y/n)? n


ready.
ready.