100 lines
2 KiB
Text
100 lines
2 KiB
Text
CHAR ARRAY text(1000)
|
|
CARD length
|
|
|
|
PROC AppendText(CHAR ARRAY part)
|
|
BYTE i
|
|
|
|
FOR i=1 TO part(0)
|
|
DO
|
|
text(length)=part(i)
|
|
length==+1
|
|
OD
|
|
RETURN
|
|
|
|
INT FUNC GetPosForWrap(BYTE lineLen INT start)
|
|
INT pos
|
|
|
|
pos=start+lineLen
|
|
IF pos>=length THEN
|
|
RETURN (length-1)
|
|
FI
|
|
|
|
WHILE pos>start AND text(pos)#32
|
|
DO
|
|
pos==-1
|
|
OD
|
|
|
|
IF pos=start THEN
|
|
pos=start+lineLen
|
|
ELSE
|
|
pos==-1
|
|
FI
|
|
RETURN (pos)
|
|
|
|
PROC PrintTextWrapped(BYTE lineLen)
|
|
INT i,pos
|
|
BYTE wrap,screenWidth=[40]
|
|
|
|
i=0
|
|
WHILE i<length
|
|
DO
|
|
pos=GetPosForWrap(lineLen,i)
|
|
IF pos-i=screenWidth-1 OR pos=length-1 THEN
|
|
wrap=0
|
|
ELSE
|
|
wrap=1
|
|
FI
|
|
|
|
WHILE i<=pos
|
|
DO
|
|
Put(text(i))
|
|
i==+1
|
|
OD
|
|
WHILE i<length AND text(i)=32
|
|
DO
|
|
i==+1
|
|
OD
|
|
|
|
IF wrap THEN
|
|
PutE()
|
|
FI
|
|
OD
|
|
RETURN
|
|
|
|
PROC Test(BYTE lineLen)
|
|
BYTE CH=$02FC
|
|
|
|
Put(125) ;clear screen
|
|
PrintF("Line length=%B%E%E",lineLen)
|
|
PrintTextWrapped(lineLen)
|
|
PrintF("%E%EPress any key to continue...")
|
|
|
|
DO UNTIL CH#$FF OD
|
|
CH=$FF
|
|
RETURN
|
|
|
|
PROC Main()
|
|
BYTE LMARGIN=$52,old
|
|
|
|
length=0
|
|
AppendText("Lorem ipsum dolor sit amet, consectetur adipiscing elit. ")
|
|
AppendText("Maecenas varius sapien vel purus hendrerit vehicula. ")
|
|
AppendText("Integer hendrerit viverra turpis, ac sagittis arcu pharetra id. ")
|
|
AppendText("Sed dapibus enim non dui posuere sit amet rhoncus tellus consectetur. ")
|
|
AppendText("Proin blandit lacus vitae nibh tincidunt cursus. ")
|
|
AppendText("Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. ")
|
|
AppendText("Nam tincidunt purus at tortor tincidunt et aliquam dui gravida. ")
|
|
AppendText("Nulla consectetur sem vel felis vulputate et imperdiet orci pharetra. ")
|
|
AppendText("Nam vel tortor nisi. Sed eget porta tortor. ")
|
|
AppendText("Aliquam suscipit lacus vel odio faucibus tempor. ")
|
|
AppendText("Sed ipsum est, condimentum eget eleifend ac, ultricies non dui.")
|
|
|
|
old=LMARGIN
|
|
LMARGIN=0 ;remove left margin on the screen
|
|
|
|
Test(40)
|
|
Test(30)
|
|
Test(20)
|
|
|
|
LMARGIN=old ;restore left margin on the screen
|
|
RETURN
|