RosettaCodeData/Task/Word-wrap/M2000-Interpreter/word-wrap.m2000
2023-07-01 13:44:08 -04:00

81 lines
2.5 KiB
Text

Module Checkit {
\\ leading space from begin of paragraph stay as is
a$={ In olden times when wishing still helped one, there
lived a king whose daughters were all beautiful, but the youngest
was so beautiful that the sun itself, which has seen so
much, was astonished whenever it shone in her face.
}
const crlf$=chr$(13)+chr$(10)
a$=replace$(crlf$, " ", a$)+crlf$
const justify=0
const flushright=1
const centered=2
const flushleft=3
\\ set layer font
Font "Tahoma"
Form 80, 50
Print "Font:";Fontname$
Print "Font size:";Mode;"pt"
Print "Bold:";Bold
Print "Italic:";Italic
\\ set left margin for Report
Cursor 10, 8 ' pos 10 row 8 (11 9 - it is 0 based)
m=Italic
Italic 1
Report centered, trim$(A$), Width-10-10
Italic m
Print @(0,79),"Press any key";
wait$=key$
Refresh 5000
charwidth=scale.x div width
For i=2000 to scale.x-charwidth step 150
\\ clear screen with 14pt fonts
Mode 12.75
\\ by default use justify, word wrap
Report a$, i
\\ we can calculate only using a negative parameter
Report a$, i, -10000
k=ReportLines
\\ print any line in differnet color
Dim a(2)
a(0)=11, 15 ' 0 to 15 are vb6 colors, we can use html colors #aabbcc, #ff2211
For j=1 to k {
Pen a(j mod 2) {
Report a$, i, 1 line j
}
}
Refresh 5000
wait$=key$
Next i
Report a$, scale.x/2, -1000
k=ReportLines
Document Doc$
Report a$, scale.x/2, k as Doc$
\\ Print document without expanding spaces
Print $(4), ' 4=proportional printing using columns, on line online, word wrap, expand to fit in columns
For i=1 to k {
Print "*";Paragraph$(Doc$, i);"*"
}
Print $(0), ' restore to non proportional printing
For i=1 to k {
Print i, size.x(Paragraph$(Doc$, i), Fontname$, Mode), size.y(Paragraph$(Doc$, i), Fontname$, Mode)
}
\\ scale.x unit in twips
Report a$, scale.x/2
\\ width unit in characters
Report a$, width/2
Print @(width div 2),
Report flushright, a$, width/2
Cursor 0, Row
I=Italic
Double
Italic 1
Report centered, a$
Italic I
Double
Normal
}
Checkit