BBS: Inland Empire Archive Date: 04-01-93 (22:21) Number: 300 From: QUINN TYLER JACKSON Refer#: NONE To: ALL Recvd: NO Subj: Source massager Conf: (2) Quik_Bas
' This file massaged by STRUCT v1.0
' STRUCT v1.0 BASIC FILE MASSAGER
' Written by Quinn Tyler Jackson
'
' This program massages BASIC files for visual ease of reading.
'
' I wrote it so that files in this echo could be written this way:
'
' FOR i = 1 TO 10
' PRINT 10
' SELECT CASE i
' CASE 1
' PRINT "One"
' CASE 2
' PRINT "Two"
' DO
' PTR = PTR + 1
' PRINT ":)"
' LOOP UNTIL Ptr = 10
' CASE ELSE
' PRINT "Else"
' END SELECT
' NEXT i
'
'
' Files like this have less chance of wrap occuring, but they are hard
' to read. This program turns the above type of thing into this, so it
' is easier to read:
'
' FOR i = 1 TO 10
' PRINT 10
' SELECT CASE i
' CASE 1
' PRINT "One"
' CASE 2
' PRINT "Two"
' DO
' Ptr = Ptr + 1
' PRINT ":)"
' LOOP UNTIL Ptr = 10
' CASE ELSE
' PRINT "Else"
' END SELECT
' NEXT i
'
DECLARE SUB BuildBox (Title$)
DEFINT A-Z
CONST LMARGIN = 3
CONST TABSIZE = 5
CONST TBLSIZE = 9
DIM TabOver$(TBLSIZE)
DIM TabBack$(TBLSIZE)
DIM SHARED InFile, OutFile
Ptr = 0
INPUT InFile$, OutFile$
InFile = FREEFILE
OPEN InFile$ FOR INPUT AS InFile LEN = 1024
OutFile = FREEFILE
OPEN OutFile$ FOR OUTPUT AS OutFile LEN = 1024
FOR i = 1 TO TBLSIZE
READ TabOver$(i), TabBack$(i)
NEXT i
PRINT #OutFile, SPACE$(LMARGIN); "' This file massaged by STRUCT v1.0"
DO UNTIL EOF(InFile)
LINE INPUT #InFile, Buffer$
Buffer$ = RTRIM$(LTRIM$(Buffer$)) + " "
IF LEFT$(Buffer$, 3) = "REM" THEN
MID$(Buffer$, 1, 3) = "' "
END IF
FOR i = 1 TO TBLSIZE
Temp$ = TabOver$(i)
IF LEFT$(Buffer$, LEN(Temp$) + 1) = Temp$ + " " THEN
Flag = -1
GOTO Jump
END IF
NEXT i
FOR i = 1 TO TBLSIZE
Temp$ = TabBack$(i)
IF LEFT$(Buffer$, LEN(Temp$) + 1) = Temp$ + " " THEN
Ptr = Ptr - 1
IF Ptr < 0 THEN
Ptr = 0
END IF
EXIT FOR
END IF
NEXT i
SELECT CASE LEFT$(Buffer$, 4)
CASE "ELSE", "CASE"
Ptr = Ptr - 1
PRINT #OutFile, SPACE$(Ptr * TABSIZE + LMARGIN) + Buffer$
Ptr = Ptr + 1
GOTO PastPrint
END SELECT
Jump:
PRINT #OutFile, SPACE$(Ptr * TABSIZE + LMARGIN) + Buffer$
PastPrint:
IF Flag THEN
Flag = 0
Ptr = Ptr + 1
END IF
LOOP
END
DATA SELECT,END SELECT
DATA IF,END IF
DATA DO,LOOP
DATA WHILE,WEND
DATA FOR,NEXT
DATA SUB,END SUB
DATA FUNCTION,END FUNCTION
DATA STATIC SUB,END SUB
DATA STATIC FUNCTION,END FUNCTION
--- Maximus 2.01wb
* Origin: VKUG/VPCC QuickBasic Echo - Richmond, BC (1:153/151)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET