home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
genapps
/
ifthen20.arj
/
IF-THEN.BAS
next >
Wrap
BASIC Source File
|
1992-01-02
|
25KB
|
774 lines
' ╔══════════════════════════════════════════════════════════════╗
' ║ ║
' ║ The Structural Pest Control Utility -- ║
' ║ for your pesky IF-THEN, DO-LOOP, WHILE ║
' ║ and SELECT mismatches .... ║
' ║ ║
' ║ I F - T H E N . B A S ║
' ║ ║
' ║ -- Howard Ballinger, 5-6-91 ║
' ║ (CompuServe ID# 71121,776) ║
' ╚══════════════════════════════════════════════════════════════╝
'revised 08/91 Dan Kubala (CompuServe ID# 73230,1754)
' Allowed print of comment statements
' Ignore comment triggers chr$(39) and "REM" when in quotes
' Split multi-statement lines for processing
' Ignore split indicator (:,COLON) when in quotes, parens or comment
' Indent nested levels - put left brackets around nests
' Allow input from non-current directory (via APPEND)
' output (*.if-) allways in current directory.
' Include FOR-NEXT recognition
'revised 12/91 Dan Kubala (CompuServe ID# 73230,1754)
' Included transfer statements (eg GOTO,RETURN,etc)
' Included pointer statements (eg GOSUB,RESTORE,etc)
' Identify Labels/Line Numbers, show their usage.
$COMPILE EXE
$OPTION CNTLBREAK OFF
$ERROR ALL OFF
$LIB ALL OFF
DEFINT A-Z
CALL ReadNMatchColor
dim SortTable$(500)
map Indent$$ * 12
Shift$ = " "
TEST$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.%&!#$|"
FlowStart$ = "~IF~DO~WHILE~SELECT~FOR~"
OneWordCmd$ = "~BEEP~CLEAR~CLOSE~CLS~END~RESET~RESUME~RETURN~RUN~" +_
"STOP~SYSTEM~"
LineLabel$ = "~"
GoToPtr$ = "~"
SubPtr$ = "~"
RestorePtr$ = "~"
cls
IF COMMAND$ = "" THEN
PRINT
PRINT " IF-THEN: The Structural Pest Control";
PRINT " Utility -- (Howard Ballinger, 5-91)"
PRINT STRING$ (80, 205);
INPUT "PowerBASIC File to Process"; F$
IF F$ = "" THEN END 1
ELSE
F$ = COMMAND$
END IF
GOSUB FilesOpen
PRINT " Opening "; InpFile$; " for input and "; OutFile$; " for output."
IF FileErr THEN BEEP: PRINT "FILE NOT FOUND": DELAY 2: END 1
Row = CSRLIN
GOSUB PrintHeader
'--- get source records
DO UNTIL EOF (1)
LastLn = Ln
INCR Ln
LineNumb$ = "": ImaLabel = 0
Flag = 0: Pre = 0: Post = 0
LOCATE Row+1, 10: PRINT USING "Reading line #### ..."; Ln
LINE INPUT #1, L0$
'--- left justify input line; create working line
L0$ = ltrim$ (L0$,any " "+chr$(9))
if L0$ = "" then goto NextLine
L0$ = rtrim$(L0$,any " "+chr$(9))
'--- look for line NUMBER; strip it off
call LineNmbr (1,L0$,x$,Split)
if Split > 0 then
LineNumb$ = X$
L0$ = right$(L0$,len(L0$)-len(x$)-1)
Flag = 1: Pre = 0: Post = 0
if instr(LineLabel$, "~"+x$+"~") = 0 then
LineLabel$ = LineLabel$ + x$ + "~"
end if
end if
LW$ = ucase$(ltrim$(L0$,any " "+chr$(9)))
'--- skip blank comment lines
if (left$(LW$,1) = chr$(39) and len(LW$) = 1) or _
(left$(LW$,3) = "REM" and len(LW$) = 3) then
goto NextLine
elseif left$(LW$,1) = chr$(39) or left$(LW$,4) = "REM " then
'--- print comment-only lines
L0L$ = L0$
LWL$ = L0$
Flag = -1: Pre = 0: Post = 0
goto PrintLine
else
'--- whack off trailing comments in work line
call EraseCmnt(LW$,"'")
call EraseCmnt(LW$,"REM")
TagCmnt$ = mid$(L0$,len(LW$)+1)
LW$ = RTRIM$ (LW$,any " "+chr$(9))
end if
'--- Now check for continued lines & splice them together ...
IF RIGHT$ (LW$, 1) = "_" THEN
DO
LW$ = RTRIM$ (LW$,any "_ "+chr$(9)): L0$ = mid$(L0$,1,len(LW$))
LINE INPUT #1, L0C$
L0C$ = LTRIM$(L0C$,any " "+chr$(9))
L0C$ = rtrim$(L0C$,any " "+chr$(9))
'--- look for line NUMBER; strip it off
call LineNmbr (1,L0C$,x$,Split)
if Split > 0 then
L0C$ = ltrim$(right$(L0C$,len(L0C$)-len(x$)-1))
end if
LWC$ = ucase$(L0C$)
'--- look for separators between continuation statements
if instr(Test$,right$(LW$,1)) > 0 and_
instr(Test$,left$(LWC$,1)) > 0 then
LW$ = LW$+" ": L0$ = L0$+" "
end if
LW$ = LW$ + LWC$: L0$ = L0$ + L0C$
call EraseCmnt(LW$,"'")
call EraseCmnt(LW$,"REM")
LW$= RTRIM$ (LW$,any " "+chr$(9)): '.....L0$= rtrim$(mid$(L0$,1,len(LW$)))
LOOP UNTIL RIGHT$ (LW$, 1) <> "_"
END IF
'--- split multi-statement lines; process singles
LWL$ = LW$: '......L0L$ = L0$
call SplitLine (LWL$,LWR$,Split)
'--- split input/output image as is done (sic) to working image
L0L$ = mid$(L0$,1,len(LWL$))
if Split > 0 then
L0R$ = ltrim$(mid$(L0$,split+1),any " "+chr$(9))
else
L0R$ = ""
end if
while LWL$ > "" '--- statement(s) remaining in line
'--- identify line labels
if LWR$ = "" and Split > 0 then
OffSet = 1: x$=fnFindNextWord$(LW$)
if X$+":" = LWL$ then
Flag = 1: Pre = 0: Post = 0
ImaLabel = 1
if instr(LineLabel$, "~"+x$+"~") = 0 then
LineLabel$ = LineLabel$ + x$ + "~"
end if
goto PrintLine
end if
end if
'--- add space so we can look left for whole word eg- "else "
LWL$ = ucase$ (rtrim$ (LWL$,any " "+chr$(9))) + " "
'--- check for Label/Line Number transfers & pointers
call Chk4Xfr (Lwl$,L0L$,Flag,Pre,Post,GoToPtr$)
call Chk4Ptr (Lwl$,L0L$,Flag,Pre,Post,SubPtr$,RestorePtr$)
'--- Conditional Processing
IF LEFT$ (LWL$, 3) = "IF " then
Flag = -1: Pre= 0: Post= 0
if RIGHT$ (LWL$, 6) = " THEN " then
Post = 1
else
call ArgInQuote (LWL$," THEN ",Split)
OffSet = Split+6
Action$ = mid$(LWL$,OffSet)
x$ = FnFindNextWord$ (LWL$)
'--- create indent if action is a flow starter
if instr(FlowStart$,"~"+x$+"~") > 0 then
Post= 1
else
'--- identify implied GOTO
if x$= "" then call LineNmbr (1,Action$,x$,Split)
x$ = rtrim$(ltrim$(x$)): Action$ = rtrim$(ltrim$(Action$))
if x$ = Action$ then
if instr(left$(x$,1),any "0123456789") > 0 or _
instr(OneWordCmd$,"~"+x$+"~") = 0 and _
x$ > "" then
L0L$ = L0L$ + " " +string$(4,chr$(16))
if instr(GoToPtr$, "~"+x$+"~") = 0 then
GoToPtr$ = GoToPtr$ + x$ +"~"
end if
end if
end if
end if
end if
'--- Flow Control Statements
elseif left$ (LWL$, 4) = "$IF " then: Flag= -1: Pre= 0: Post= 1
elseIF LEFT$ (LWL$, 3) = "DO " then: Flag= -1: Pre= 0: Post= 1
elseIF LEFT$ (LWL$, 6) = "WHILE " then: Flag= -1: Pre= 0: Post= 1
elseIF LEFT$ (LWL$, 7) = "SELECT " THEN: Flag= -1: Pre= 0: Post= 1
elseIF LEFT$ (LWL$, 4) = "FOR " THEN: Flag= -1: Pre= 0: Post= 1
elseif left$ (LWL$, 6) = "$ELSE " then: Flag= -1: Pre= 1: Post= 1
elseIF LEFT$ (LWL$, 5) = "ELSE " THEN: Flag= -1: Pre= 1: Post= 1
elseIF LEFT$ (LWL$, 7) = "ELSEIF " THEN: Flag= -1: Pre= 1: Post= 1
elseIF LEFT$ (LWL$, 5) = "CASE " THEN: Flag= -1: Pre= 1: Post= 1
elseif left$ (LWL$, 7) = "$ENDIF " then: Flag= -1: Pre= 1: Post= 0
elseIF LEFT$ (LWL$, 5) = "LOOP " THEN: Flag= -1: Pre= 1: Post= 0
elseIF LEFT$ (LWL$, 5) = "WEND " THEN: Flag= -1: Pre= 1: Post= 0
elseIF LEFT$ (LWL$, 11)= "END SELECT " THEN: Flag= -1: Pre= 1: Post= 0
elseIF LEFT$ (LWL$, 7) = "END IF " THEN: Flag= -1: Pre= 1: Post= 0
elseIF LEFT$ (LWL$, 5) = "NEXT " THEN: Flag= -1: Pre= 1: Post= 0
'--- Inclusion Indicators
elseIF LEFT$ (LWL$, 9) = "$INCLUDE " THEN: Flag= -1: Pre= 0: Post= 0
elseif left$ (LWL$, 8) = "$INLINE " then: Flag= -1: Pre= 0: Post= 0
elseif left$ (LWL$, 6) = "$LINK " then: Flag= -1: Pre= 0: Post= 0
elseif left$ (LWL$, 8) = "DECLARE " then: Flag= -1: Pre= 0: Post= 0
'--- Procedure Definers
elseif left$ (LWL$, 4) = "SUB " then: Flag= -1: Pre= 0: Post= 0
elseif left$ (LWL$, 4) = "DEF " then: Flag= -1: Pre= 0: Post= 0
elseif left$ (LWL$, 9) = "FUNCTION " then: Flag= -1: Pre= 0: Post= 0
elseif left$ (LWL$, 8) = "END SUB " then: Flag= -1: Pre= 0: Post= 0
elseif left$ (LWL$, 8) = "END DEF " then: Flag= -1: Pre= 0: Post= 0
elseif left$ (LWL$,13) = "END FUNCTION " then: Flag=-1: Pre= 0: Post= 0
'--- Comment Identifiers
elseif left$ (LWL$, 1) = chr$(39) then: Flag= -1: Pre= 0: Post= 0
elseif left$ (LWL$, 4) = "REM " then: Flag= -1: Pre= 0: Post= 0
'--- Procedure Transfers
elseif left$ (LWL$, 3) = "ON " then: Flag= -1: Pre= 0: Post= 0
elseif left$ (LWL$, 5) = "EXIT " then: Flag= -1: Pre= 0: Post= 0
elseif left$ (LWL$, 5) = "GOTO " then: Flag= -1: Pre= 0: Post= 0
elseif left$ (LWL$, 6) = "GOSUB " then: Flag= -1: Pre= 0: Post= 0
elseif left$ (LWL$, 5) = "CALL " then: Flag= -1: Pre= 0: Post= 0
elseif left$ (LWL$, 7) = "RETURN " then: Flag= -1: Pre= 0: Post= 0
elseif left$ (LWL$, 7) = "RESUME " then: Flag= -1: Pre= 0: Post= 0
'--- Program Transfers
elseif left$ (LWL$, 6) = "CHAIN " then: Flag= -1: Pre= 0: Post= 0
elseif left$ (LWL$, 8) = "EXECUTE " then: Flag= -1: Pre= 0: Post= 0
elseif left$ (LWL$, 4) = "RUN " then: Flag= -1: Pre= 0: Post= 0
elseif left$ (LWL$, 6) = "SHELL " then: Flag= -1: Pre= 0: Post= 0
elseif left$ (LWL$, 5) = "STOP " then: Flag= -1: Pre= 0: Post= 0
elseif left$ (LWL$, 7) = "SYSTEM " then: Flag= -1: Pre= 0: Post= 0
elseif left$ (LWL$, 4) = "END " then: Flag= -1: Pre= 0: Post= 0
end if
PrintLine:
IF Flag THEN
if ImaLabel = 1 then LineNumb$= L0L$: L0L$ = ""
if LastLn >< Ln then
if instr(left$(LineNumb$,1),any "0123456789") > 0 then
rset Indent$$ = LineNumb$
else
lset Indent$$ = LineNumb$
end if
LastLn = Ln
PRINT #2, USING$ ("#### ", Ln);
'--- put Tag Comment only on 1st part of statement
L0L$ = rtrim$(L0L$) + " " + ltrim$(TagCmnt$): TagCmnt$ = ""
else
rset Indent$$ = ""
print #2, " ";chr$(34);" ";
end if
print #2, Indent$$;" ";
'.....lprint Ln,flag;imalabel;linenumb$,mid$(L0L$,1,20)
on error goto BasicError
if Pre = 0 and Post = 1 then 'Do, While, Select, If-Then
Shift$ = left$(Shift$,len(Shift$)-2)
Shift$ = Shift$ + " "+chr$(218)
print #2, Shift$;ltrim$(L0L$,any " "+chr$(9))
Shift$ = left$(Shift$,len(Shift$)-2)
Shift$ = Shift$ + " "+chr$(179)+" "
elseif Pre = 1 and Post = 1 then 'Else, ElseIf, Case
Shift$ = left$(Shift$,len(Shift$)-2)
print #2, Shift$;ltrim$(L0L$,any " "+chr$(9))
Shift$ = Shift$ + " "
elseif Pre = 1 and Post = 0 then 'Loop, Wend, End Select, End If
Shift$ = left$(Shift$,len(Shift$)-4)
Shift$ = Shift$ + " "+chr$(192)
print #2, Shift$;ltrim$(L0L$,any " "+chr$(9))
Shift$ = left$(Shift$,len(Shift$)-2)
Shift$ = Shift$ + " "
else
print #2, Shift$;ltrim$(L0L$,any " "+chr$(9))
end if
on error goto 0
END IF
Flag = 0: ImaLabel = 0
LWL$ = LWR$: '...L0L$ = L0R$
call SplitLine (LWL$,LWR$,Split)
'--- split input/output image as is done (sic) to working image
L0L$ = mid$(L0R$,1,len(LWL$))
if Split > 0 then
L0R$ = ltrim$(mid$(L0R$,split+1) ,any " "+chr$(9))
else
L0R$ = ""
end if
wend 'single statements
NextLine:
LOOP 'record read
print: print: print spc(9);"Processing Labels & Line Numbers": print
'--- identify Labels and Line Numbers
'...call TableLoad(LineLabel$,"Line Labels")
call TableLoad(GoToPtr$,"GoTo Objects")
call TableLoad(SubPtr$,"GoSub Calls")
call TableLoad(RestorePtr$,"Restore Pointers")
call Comparator (LineLabel$,1,"Line Labels/Numbers NOT used")
call Comparator (GoToPtr$, 2,"GoTo = GoSub (TROUBLE ????)")
call Comparator (GoToPtr$, 3,"GoTo = Restore (TROUBLE ??)")
call Comparator (SubPtr$, 4,"GoSub = Restore (TROUBLE ?)")
QUITIT:
close #2
PRINT: PRINT: PRINT " (Requires LIST.COM)"
LOCATE CSRLIN-2, 1, 1
PRINT " "; OutFile$; " is complete. LIST file ?? ";
DO: K$ = UCASE$ (INKEY$): LOOP UNTIL (K$) = "Y" OR (K$) = "N"
IF K$ = "Y" THEN
CLS
LOCATE 4, 10: PRINT "USE CURSOR KEYS TO SCROLL FILE"
LOCATE 6, 15: PRINT "Escape to Quit
LOCATE 8, 10: PRINT "Press any Key to start LIST"
DO: LOOP WHILE INKEY$ = ""
SHELL "LIST " + OutFile$
CLS
ELSE
PRINT: PRINT: PRINT
END IF
END
FilesOpen:
F$ = UCASE$ (F$)
IF INSTR (F$, ".") = 0 THEN
InpFile$ = F$ + ".BAS"
ELSE
InpFile$ = F$
END IF
OutFile$ = InpFile$
DO until instr(OutFile$,"\") = 0
OutFile$ = mid$(OutFile$,instr(OutFile$,"\")+1)
LOOP
OutFile$ = EXTRACT$ (OutFile$, ".") + ".IF-"
on error goto BasicError
OPEN InpFile$ FOR INPUT AS 1
OPEN OutFile$ FOR OUTPUT AS 2
on error goto 0
RETURN
BasicError:
if ERR = 53 then
print InpFile$;" FILE NOT FOUND"
delay 2
elseif ERR = 5 then
print
print " IMPROPER END OF NEST - see end of output listing"
resume QUITIT
end if
end
PrintHeader:
PRINT #2, " " + DATE$ + " at " + TIME$
PRINT #2, " LISTING OF STRUCTURAL STATEMENTS IN "; InpFile$;
PRINT #2, " FOR ERROR ANALYSIS"
PRINT #2, ""
print #2, "Line";spc(2);"Stmnt#";spc(8); _
"Statement, Flow Control -or- Line Numbered"
print #2, ""
RETURN
SUB ReadNMatchColor
LOCAL A ' sets COLOR to match the
A = SCREEN (CSRLIN, POS, 1) ' color presently on the
COLOR A MOD 16, A \ 16 ' display (at cursor position).
END SUB
'--------------------------------------------------------------------------
SUB EraseCmnt(T$,Cmnt$)
Shared Test$
Local Posn,Quote,Split
' This sub determines if a Comment indicator is in quotes. It exists to
' allow us to strip comments but to retain the quoted material so that we
' can later identify INCLUDE files, etc
Posn = 1
Split = instr(Posn,T$,Cmnt$)
if Split = 0 then
exit SUB
elseif Cmnt$ = "REM" then '--- check for whole word
while -1
if split = 1 then
if (Split+2 = len(T$) or instr(Test$,mid$(T$,Split+3,1)) > 0) then
exit SUB '--- we have a REM
end if
else
if instr(Test$,mid$(T$,Split-1,1)) = 0 and _
(Split+2 = len(T$) or instr(Test$,mid$(T$,Split+3,1)) > 0) then
exit SUB '--- we have a REM
end if
end if
Posn = Split+3
Split = instr(Posn,T$,Cmnt$)
if Split = 0 then exit SUB
wend
end if
Posn = 1
DO
Quote = instr(Posn,T$,chr$(34)) 'open quote
if Quote = 0 or Split < Quote then
T$ = rtrim$(left$(T$,Split-1),any " "+chr$(9))
exit SUB
else
Posn = Quote+1
Quote = instr(Posn,T$,chr$(34)) 'close quote
if Quote = 0 then 'close quote is missing
exit SUB
elseif Split < Quote then 'look for next split
Split = instr(Quote,T$,Cmnt$)
if Split = 0 or Split = len(T$) then
exit SUB
elseif Cmnt$ = "REM" then '--- check for whole word
while -1
if instr(Test$,mid$(T$,Split-1,1)) = 0 and _
(Split+2 = len(T$) or_
instr(Test$,mid$(T$,Split+3,1)) > 0) then
exit LOOP '--- we have a REM
else
Posn = Split+3
Split = instr(Posn,T$,Cmnt$)
if Split = 0 then exit SUB
end if
wend
end if
else
Posn = Quote+1 'look for next open quote
if Posn > len(T$) then exit SUB
end if
end if
LOOP
exit sub
end sub
'--------------------------------------------------------------------------
SUB SplitLine (T$,T1$,Split)
local Posn,Quote,Kloser$
' This sub determines if a statement separator is in quotes. It exists to
' allow us to split statements but to retain the quoted material so that we
' can later identify INCLUDE files, etc
Posn = 1
Split = instr(T$,":")
if Split = 0 or Split = len(T$) then
T1$ = ""
exit SUB
else
DO
Quote = instr(Posn,T$,any "("+chr$(34)) 'open quote/paren
if Quote = 0 or Split < Quote then
T1$ = ltrim$(right$(T$,len(T$)-Split),any " "+chr$(9))
T$ = rtrim$(left$(T$,Split-1),any " "+chr$(9))
exit SUB
else
Kloser$ = mid$(T$,Quote,1)
if Kloser$ >< chr$(34) then
Kloser$ = ")"
end if
Posn = Quote+1
Quote = instr(Posn,T$,Kloser$) 'close quote/paren
if Quote = 0 then 'close quote is missing
Split = 0
T1$ = ""
exit SUB
elseif Split < Quote then 'look for next split
Split = instr(Quote+1,T$,":")
if Split = 0 or Split = len(T$) then
T1$ = ""
exit SUB
end if
end if
Posn = Quote+1 'look for next open quote
if Posn > len(T$) then exit SUB
end if
LOOP
end if
end sub
'--------------------------------------------------------------------------
DEF FnFindNextWord$ (T$)
shared OFFSET, PREVCHAR$, TEST$
local FLAG, X$, THEWORD$
'This function returns the next word in T$ starting at OFFSET (global).
'A word is begins with the first alphabetic character encountered and
'continues until a character outside the set (A-Z, 0-9, ".%$!") is
'encountered.
'OFFSET is set to the first character position after the word.
'PREVCHAR$ is set to the char preceeding the word (to find % for constants)
FLAG = 1
THEWORD$ = ""
PREVCHAR$ = ""
X$ = ""
while OFFSET <= LEN (T$) 'Find first alpha character
X$ = mid$ (T$, OFFSET, 1)
if X$ >= "A" and X$ <= "Z" then EXIT LOOP
OFFSET = OFFSET + 1
wend
if X$ < "A" or X$ > "Z" then 'None found
OFFSET = len (T$)
FnFindNextWord$ = ""
EXIT DEF
end if
if OFFSET > 1 then
PREVCHAR$ = mid$ (T$, OFFSET - 1, 1)
if PrevChar$ = "%" or PrevChar$ = "&" then TheWord$ = PrevChar$
end if
while FLAG
THEWORD$ = THEWORD$ + X$
if OFFSET <= len (T$) then
OFFSET = OFFSET + 1
else
FLAG = 0
end if
X$ = mid$ (T$, OFFSET, 1)
if X$ = "" then
Flag = 0
elseif instr (TEST$, X$) = 0 then
FLAG = 0 'End of word found
end if
wend
FnFindNextWord$ = THEWORD$
END DEF
'----------------------------------------------------------------------------
SUB ArgInQuote (T$,ArgMnt$,Split)
' This procedure determines if an instring value is in quotes or parens.
' It returns a value, Split, only if the value is a string and not
' an arguement.
Local Kloser$,Posn,Quote
Split = instr(T$,ArgMnt$)
if Split = 0 then
exit sub
else
Posn = 1
DO
Quote = instr(Posn,T$,any "("+chr$(34)) 'open paren/quote
if Quote = 0 or Split < Quote then
exit SUB
else
Kloser$ = mid$(T$,Quote,1)
if Kloser$ >< chr$(34) then
Kloser$ = ")"
end if
Posn = Quote+1
Quote = instr(Posn,T$,Kloser$) 'close paren/quote
if Quote = 0 then 'close quote is missing
Split = 0
exit SUB
elseif Split < Quote then 'look for next split
Split = instr(Quote+1,T$,ArgMnt$)
if Split = 0 then exit SUB
end if
Posn = Quote+1 'look for next open quote
if Posn > len(T$) then exit SUB
end if
LOOP
end if
end sub
'----------------------------------------------------------------------
SUB LineNmbr (Posn,T$,x$,Split)
if mid$(T$,Posn,1) = " " then
while mid$(T$,Posn,1) = " " and Posn < len(T$)
Posn = Posn + 1
wend
end if
Split = instr(mid$(T$,Posn,1), any "0123456789")
if Split > 0 then
x$ = extract$(mid$(T$,Posn)," ")
end if
end sub
'----------------------------------------------------------------------
SUB TableLoad (T$,Hdr$)
Shared SortTable$(),Indent$$
Local E,I,Items,S,x$
'--- Load Sort Table
Items = tally (T$,"~") -1
if Items > 0 then
S = 2
for I = 1 to Items
E = instr(S,T$,"~")
if E = 0 then
exit for
else
x$ = mid$(T$,S,E-S)
if instr(left$(x$,1), any "0123456789") > 0 then
rset indent$$ = x$
SortTable$(I) = indent$$
else
SortTable$(I) = x$
end if
S = E+1
end if
next I
array sort SortTable$(1) for Items
print #2, " "
print #2, Hdr$
for I = 1 to Items
print #2, " ";SortTable$(I)
next I
end if
end sub
'----------------------------------------------------------------------
Sub Comparator (T$,Kase,Msg$)
Shared Indent$$,SortTable$()
Shared GoToPtr$,SubPtr$,RestorePtr$
Local E,Found,I,Items,Misses,S,x$
Items = tally (T$,"~") -1
if Items > 0 then
Misses = 0
S = 2
for I = 1 to Items
E = instr(S,T$,"~")
if E = 0 then
exit if
else
x$ = mid$(T$,S,E-S)
Found = 0
select case Kase
case 1
if instr(GoToPtr$, "~"+x$+"~") = 0 and _
instr(SubPtr$, "~"+x$+"~") = 0 and _
instr(RestorePtr$, "~"+x$+"~") = 0 then Found = 1
case 2
if Instr(SubPtr$, "~"+x$+"~") >< 0 then Found = 1
case 3,4
if instr(RestorePtr$, "~"+x$+"~") >< 0 then Found = 1
case else
print #2, "Compare Option, ";Kase;", Not Available
exit sub
end select
If Found > 0 then
incr Misses
if instr(left$(x$,1),any "0123456789") > 0 then
rset indent$$ = x$
SortTable$(Misses) = indent$$
else
SortTable$(Misses) = x$
end if
end if
end if
S = E+1
next I
if Misses > 0 then
array sort SortTable$() for Misses
print #2, " "
print #2, Msg$
for I = 1 to Misses
print #2, " ";SortTable$(I)
next I
end if
end if
end Sub
'-----------------------------------------------------------------------
Sub Chk4Xfr (LWL$,L0L$,Flag,Pre,Post,GoToPtr$)
shared OffSet
local x$,ArgPos,ArgLen,Split
call ArgInQuote (LWL$,"GOTO ",ArgPos): ArgLen = 4
if ArgPos = 0 then call ArgInQuote (LWL$,"RESUME ",ArgPos): ArgLen = 6
if ArgPos = 0 then call ArgInQuote (LWL$,"RETURN ",ArgPos): ArgLen = 6
if ArgPos > 0 then
Flag = -1: Pre= 0: Post= 0
OffSet = ArgPos + ArgLen
while -1
call LineNmbr (OffSet,LWL$,x$,Split)
if Split = 0 then
x$=fnFindNextWord$(LWL$)
Offset = OffSet + 1
if x$ = "NEXT" then exit sub
else
x$ = extract$(x$,",")
OffSet = OffSet + len(x$) + 1
if x$ = "0" and left$(LWL$,9) = "ON ERROR " or _
mid$(LWL$,ArgPos,6) = "RESUME" then exit sub
end if
if len(x$) = 0 then exit sub
if instr(GoToPtr$, "~"+x$+"~") = 0 then
GoToPtr$ = GoToPtr$ + x$ +"~"
end if
if OffSet => len(LWL$) then exit loop
Loop
L0L$ = L0L$ + " " + string$(4,chr$(16))
end if
end sub
'--------------------------------------------------------------------
Sub Chk4Ptr (Lwl$,L0L$,Flag,Pre,Post,SubPtr$,RestorePtr$)
shared OffSet
local x$,ArgPos,ArgLen,Split,Kase
call ArgInQuote (LWL$,"GOSUB ",ArgPos): ArgLen = 5: Kase = 1
if ArgPos = 0 then
call ArgInQuote (LWL$,"RESTORE ",ArgPos)
ArgLen = 7: Kase = 2
end if
if ArgPos > 0 then
Flag = -1: Pre= 0: Post= 0
OffSet = ArgPos+ArgLen
While -1
call LineNmbr (OffSet,LWL$,x$,Split)
if Split = 0 then
x$=fnFindNextWord$(LWL$)
Offset = Offset + 1
else
x$ = extract$(x$,",")
OffSet = OffSet + len(x$) + 1
end if
if len(x$) = 0 then exit sub
Select Case Kase
case 1
if instr(SubPtr$, "~"+x$+"~") = 0 then
SubPtr$ = SubPtr$ + x$ +"~"
end if
case 2
if instr(RestorePtr$, "~"+x$+"~") = 0 then
RestorePtr$ = RestorePtr$ + x$ +"~"
end if
end select
if OffSet => len(LWL$) then exit loop
Loop
L0L$ = L0L$ + " " + chr$(17) + "==" + chr$(16)
end if
end sub