DECLARE SUB WaitForNextPage (RetFlag AS INTEGER)
DECLARE SUB ShowCurrentPage (LgndFlag AS INTEGER)
DECLARE SUB Prnt (text AS STRING)
DECLARE SUB DoCmd (Cmd AS STRING)
' Programmed by Kewbie Newbie
' 07/06/00 - program coded
' 01/01/06 - updated doc and added a couple features
CONST FALSE = 0
CONST TRUE = NOT FALSE
DIM SHARED prntCol AS INTEGER
DIM SHARED CurrentPage AS INTEGER, LastPage AS INTEGER
DIM SHARED cmdFlag AS INTEGER
DIM SHARED TabWidth AS INTEGER
DIM SHARED Done AS INTEGER
DIM SHARED Dlm AS STRING
DIM SHARED Production AS INTEGER
DIM Answer AS STRING
COLOR 0, 7
Production = FALSE
CurrentPage = 1
LastPage = 3
TabWidth = 8
Done = FALSE
Dlm = "`"
'Prnt "'" + Dlm + "'": END
DO
ShowCurrentPage (FALSE)
WaitForNextPage (FALSE)
LOOP UNTIL Done
END
Legend.01:
DATA "`h``g25,1``c<Page Down>, or <End>``n`"
DATA `~`
Legend.02:
DATA "`h``g25,1``c<Page Up>, <Page Down>, or <End>``n`"
DATA `~`
Legend.03:
DATA "`h``g25,1``c<Page Up>, or <End>``n`"
DATA `~`
PageError:
DATA "`g12,1``k9,7``cThis error should not occur.`"
DATA "`g13,1``h``cCheck your LastPage variable`"
DATA "`#`"
FunctionList:
DATA "`l`"
DATA "This simple text formatter has `h`14`n` general purpose commands."
DATA "All commands AND "
DATA "their parameters are enclosed in `h`grave accents`n`, also called"
DATA "`h`back ticks`n`."
DATA "This command delimiter can be changed to a character that is more"
DATA "convenient, if desired. See documentation below."
DATA "The `h`grave accent`n` key is usually found on the main keyboard"
DATA "next to the '1' key. The character looks like this:`l`
DATA "`d;`"
DATA ";z;;t;;t;;l;;t;`;t;;l;;n;;d`;"
DATA "The commands may be entered in either upper or lower case. They"
DATA "are:`p`"
DATA "`t``¨``h`K`n`foreground,background`¨``w40``t`"
DATA "`k9,7`c`k10,7`h`k11,7`a`k12,7`n`k5,7`g`k14,7`e `n`"
DATA "the text color`p``w`"
DATA "`t``¨``h`H`n``¨``w40``t``h`hilight`n` text`p``w`"
DATA "`t``¨``h`N`n``¨``w40``t`normal text`n``p``w`"
DATA "`t``¨``h`R`n``¨``w39``t``r` reverse `n` text`n``p``w`"
DATA "`t``¨``h`Z`n``¨``w39``t``z` reverse hilight `n` text`n``p``w`"
DATA "`t``¨``h`D`n``¨``w40``t`insert a `h`double quote`n` (`h``D``n`)"
DATA "in the text`p``w`"
DATA "`t``¨``h`D`n`single char`¨``w40``t`sets the command delimiter to"
DATA "`h`char`n``w``p`
DATA "`g25,1``h``chit a key for next page`"
DATA "`q``e``n``l`"
DATA "(Simple text formatter commands continued)`p`"
DATA "`t``¨``h`L`n`numLines`¨``w40``t`inserts `h`numLines line`n` breaks`l`"
DATA "`t`(if `h`numLines`n` is omitted, default is 1)`p``w`"
DATA "`t``¨``h`P`n``¨``w40``t`insert `h`paragraph`n` break`p``w`"
DATA "`t``¨``h`T`n``¨``w40``t``h`tab`n` to next column`p``w`"
DATA "`t``¨``h`W`n`numCols`¨``w40``t`set tab column `h`width`n``l``w`"
DATA "`w40``t`(if `h`numCols`n` is omitted, default is 8)`p``w`"
DATA "`t``¨``h`C`n`text`¨`*`w40``t``h`center`n` text`p``w`"
DATA "`t``¨``h`J`n`text`¨`*`w40``t`right-`h`justify`n` text`p``w`"
DATA "`t``¨``h`G`n`row,column`¨``w40``t``h`goto`n` (move cursor) to row,column"
DATA "`l2``w`"
DATA "*`h`Note:`n``t`It is possible to overlay text with both the `h`C`n` and"
DATA "`h`J`n` commands.`l``t`Also, both of these commands operate on an 80"
DATA "character line."
DATA "`g25,1``h``chit a key for next page`"
DATA "`q``e``n``l`"
DATA "There are a few special purpose commands, added mainly to allow for"
DATA "providing these help screens:`p`"
DATA "`t``¨``h`¨`n``¨``w40``t`prints a `h`grave accent`n``l`"
DATA "`t`('¨'is chr$(168))`w``p`
DATA "`t``¨``h`E`n``¨``w40``t``h`erases`n` (clears) the screen`w``p`
DATA "`t``¨``h`Q`n``¨``w40``t``h`query`n` waits for a key to present"
DATA "`l``t`next page`w``p`
DATA "`t``¨``h`#`n``¨``w40``t`is used to end the program after an`l`"
DATA "`t`error occurs`w``p`
DATA "`g25,1``h``chit a key for next page`"
DATA "`q``e``n``l`"
DATA "And finally, there are some additional items,"
DATA "the `h`end of page`n` mark, the `h`LastPage`n` variable,"
DATA "the `h`ShowPage`n` subroutine, and the `h`Production`n` variable.`p`"
DATA "The `h`end of page`n` mark, `h``¨`~`¨``n` must appear on a DATA line"
DATA "by itself. E.g.:`p`"
DATA "DATA `¨`~`¨``p`"
DATA "There `h`must`n` be an `h`end of page`n` mark at the end of each page,"
DATA "otherwise the pages will run together.`p`"
DATA "The `h`LastPage`n` variable must be set to the number of pages in the"
DATA "document.`p`"
DATA "The `h`ShowPage`n` subroutine has a `h`SELECT`n` statement which must"
DATA "be modified to account for each page of the document.`p`"
DATA "And finally, setting the `h`Production `n`variable to TRUE will disable"
DATA "the display of this help information if the <Home> key is hit."
DATA "`g25,1``h``chit <Home> to return to the main document`"
DATA `~`
Page.01:
DATA "`h``cThis is page one.`"
DATA "`l``n`This simple text formatter requires a minimum of `h`two`n` pages."
DATA "`h``g12,1``cend of page one`"
DATA "`g6,18``r` `n`"
DATA "`g7,10`hit the `z` <Home> `n` key to see the Text Formatter documentation"
DATA "`g8,18``r` `n`"
DATA `~`
Page.02:
DATA "`h``cThis is page two.`"
DATA "`l``n`This simple text formatter requires a minimum of `h`two`n` pages."
DATA "`g6,18``r` `n`"
DATA "`g7,10`hit the `z` <Home> `n` key to see the Text Formatter documentation"
DATA "`g8,18``r` `n`"
DATA "`h``g12,1``cend of page two`"
DATA `~`
Page.03:
DATA "`h``cThis is page three.`"
DATA "`l``n`This simple text formatter requires a minimum of `h`two`n` pages."
DATA "`g6,18``r` `n`"
DATA "`g7,10`hit the `z` <Home> `n` key to see the Text Formatter documentation"
DATA "`g8,18``r` `n`"
DATA "`h``g12,1``cend of page three`"
DATA `~`
SUB DoCmd (Cmd AS STRING)
DIM Kmd AS STRING * 1
DIM cFg AS INTEGER, cBg AS INTEGER, Cma AS INTEGER
DIM Row AS INTEGER, Col AS INTEGER
DIM badCmd AS INTEGER
DIM ToNextTab AS INTEGER
cmdFlag = TRUE
badCmd = FALSE
Kmd = UCASE$(Cmd)
Cmd = MID$(Cmd, 2)
SELECT CASE Kmd
CASE "K"
Cma = INSTR(Cmd, ",")
cFg = VAL(LEFT$(Cmd, Cma - 1))
cBg = VAL(MID$(Cmd, Cma + 1))
COLOR cFg, cBg
CASE "H"
COLOR 15, 7
CASE "N"
COLOR 0, 7
CASE "R"
COLOR 7, 0
CASE "Z"
COLOR 15, 0
CASE "D" '
IF Cmd$ = "" THEN
Prnt (CHR$(34))
cmdFlag = TRUE
ELSE
IF LEN(Cmd$) = 1 THEN Dlm = Cmd$ ELSE badCmd = TRUE
END IF
CASE "L"
Col = VAL(Cmd)
IF Col < 1 THEN Col = 1
FOR Row = 1 TO Col
PRINT
NEXT Row
prntCol = 0
CASE "P"
PRINT : PRINT
prntCol = 0
CASE "C"
LOCATE , (41 - LEN(Cmd) / 2)
PRINT Cmd;
' prntCol = 0
CASE "J"
LOCATE , (81 - LEN(Cmd))
PRINT Cmd
prntCol = 0
CASE "T"
ToNextTab = TabWidth - ((prntCol + TabWidth) MOD TabWidth)
prntCol = prntCol + ToNextTab
PRINT SPACE$(ToNextTab);
CASE "W"
TabWidth = VAL(Cmd)
IF TabWidth < 1 THEN TabWidth = 8
CASE "G"
Cma = INSTR(Cmd, ",")
Row = VAL(LEFT$(Cmd, Cma - 1))
Col = VAL(MID$(Cmd, Cma + 1))
LOCATE Row, Col
prntCol = Col - 1
CASE "¨" ' chr$(168)
Prnt (Dlm)
cmdFlag = TRUE
CASE "E"
CLS
prntCol = 0
CASE "Q"
WHILE INKEY$ = "": WEND
CASE "#"
END
CASE ELSE
badCmd = TRUE
END SELECT
IF badCmd THEN
CLS
LOCATE 12, 38
COLOR 10, 7: PRINT Kmd; " ";
COLOR 11, 7: PRINT Cmd; "?"
COLOR 7, 7
PLAY "O2 L10 ML E C# O2 L10 ML E C# O3 L64 ML E C# E C# E C# E C# E C# E C#"
SLEEP: END
END IF
END SUB
SUB Prnt (text AS STRING)
DIM pTxt AS STRING, Wrd AS STRING
DIM sLoc AS INTEGER, lWrd AS INTEGER
pTxt = text + " "
DO
sLoc = INSTR(pTxt, " ")
Wrd = LEFT$(pTxt, sLoc - 1)
pTxt = MID$(pTxt, sLoc + 1)
lWrd = LEN(Wrd)
IF lWrd + prntCol > 79 THEN
PRINT
prntCol = 0
END IF
IF prntCol <> 0 AND NOT cmdFlag THEN
Wrd = " " + Wrd
lWrd = lWrd + 1
END IF
cmdFlag = FALSE
PRINT Wrd;
prntCol = prntCol + lWrd
LOOP UNTIL pTxt = ""
END SUB
SUB ShowCurrentPage (LgndFlag AS INTEGER)
DIM Cmd AS STRING, text AS STRING
DIM Kst AS INTEGER, Knd AS INTEGER
DIM EOP AS STRING * 3
IF NOT LgndFlag THEN
SELECT CASE CurrentPage
CASE 1
RESTORE Page.01
CASE 2
RESTORE Page.02
CASE 3
RESTORE Page.03
CASE ELSE
RESTORE PageError
END SELECT
CLS
END IF
Col = 0
EOP = Dlm + "~" + Dlm
DO
READ text
IF text = EOP THEN EXIT DO
DO
Kst = INSTR(text, Dlm)
IF Kst THEN
Knd = INSTR(Kst + 1, text, Dlm)
Cmd = MID$(text, Kst + 1, Knd - Kst - 1)
Prnt (LEFT$(text, Kst - 1))
text$ = MID$(text, Knd + 1)
DoCmd (Cmd)
ELSE
Prnt (text)
text = ""
END IF
LOOP UNTIL text = ""
LOOP
END SUB
SUB WaitForNextPage (RetFlag AS INTEGER)
DIM Answer AS STRING
DIM Accepted AS INTEGER
DIM FuncFlag AS INTEGER
SELECT CASE CurrentPage
CASE 1
RESTORE Legend.01
CASE IS <> LastPage
RESTORE Legend.02
CASE ELSE
RESTORE Legend.03
END SELECT
ShowCurrentPage (TRUE)
IF RetFlag THEN EXIT SUB
Accepted = FALSE
DO
Answer = ""
WHILE LEN(Answer) <> 2: Answer = INKEY$: WEND
SELECT CASE RIGHT$(Answer, 1)
CASE "I" ' Page Up
IF CurrentPage > 1 THEN
CurrentPage = CurrentPage - 1
Accepted = TRUE
ELSE
PLAY "O3 L64 ML E C# E C# E C# E C# E C# E C#"
END IF
CASE "Q" ' Page Down
IF CurrentPage < LastPage THEN
CurrentPage = CurrentPage + 1
Accepted = TRUE
ELSE
PLAY "O3 L64 ML E C# E C# E C# E C# E C# E C#"
END IF
CASE "O" ' End
CLS
Done = TRUE
Accepted = TRUE
CASE "G" ' Home
IF NOT Production THEN
CLS
FuncFlag = NOT FuncFlag
RESTORE FunctionList
ShowCurrentPage (FuncFlag)
IF NOT FuncFlag THEN WaitForNextPage (TRUE)
END IF
CASE ELSE
PLAY "O3 L32 ML E C#"
END SELECT
LOOP UNTIL Accepted
END SUB |