home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
progbas
/
qconvert.arj
/
QCONVERT.BAS
next >
Wrap
BASIC Source File
|
1991-11-19
|
4KB
|
142 lines
dim shared subnum(300):dim shared subname$(300)
TOP:
com$=command$
length=len(com$)
max=(length/2)+1
dim arg$(max)
true=-1:false=0:i=1:num=0:inword=true
while i <= length
ch$=mid$(com$,i,1)
if ch$ <> " " then
if not inword then inword = true
arg$(num) = arg$(num) + ch$
elseif inword then
num =num+1
inword=false
end if
i = i+1
wend
y=1
if not arg$(0)="" then goto BEGINNING
HELP:
print" "
print"QCONVERT converts QuickBASIC programs to BASIC. (C) 1986 David A. Wesson"
print" "
print"Syntax: QCONVERT [d:]filename [d:]newfile "
print" where filename = original file [drive optional] "
print" newfile = new file to be created [drive optional]"
print"
print" NOTE: The original file must be in ASCII.
print" QuickBasic is a trademark owned by MicroSoft.
print" Incompatabilities in commands are not handled.
system
BEGINNING:
infile$=arg$(0)
on error goto NOFIND
open infile$ for input as #1
outfile$=arg$(1)
if outfile$="" then goto BADFILE
if outfile$=infile$ then goto BADFILE
open outfile$ for output as #2
ROUTINE:
color 15:print"QCONVERT:";:color 7:print"QuickBASIC to BASIC converter"
print"Converting ";infile$;" to ";outfile$
print"Hit [Ctrl]+[Break] to terminate."
print" Starting time: ";time$
print" Program lines: "
print"Processing line: "
z=0
CYCLE:
if eof(1) then goto REPLACENAMES
line input #1,l$
z=z+1
locate 5,17:print z
SUBNAME:
if left$(l$,1)=chr$(39)_
or left$(l$,3)="REM"_
or left$(l$,3)="rem"_
or left$(l$,1)=chr$(9)_
or left$(l$,1)>chr$(122)_
or left$(l$,1)<chr$(65)_
or left$(l$,1)=chr$(32) then goto CYCLE
colonpos=instr(1,l$,chr$(58))
s=s+1
subname$(s)=left$(l$,colonpos-1)
subnum(s)=z*10
goto CYCLE
REPLACENAMES:
close #1
open infile$ for input as #1
z=0
SEARCH:
if eof(1) then goto FINISH
line input #1,l$
z=z+1
locate 6,17:print z
if left$(l$,1)=chr$(39) or left$(l$,3)="REM"_
or left$(l$,3)="rem" then
goto DUMP
end if
n=0
NEXTNAME:
for n = 1 to s
replace$=subname$(n)
new$=str$(subnum(n))
NEXTSEARCH:
lfpos=instr(1,l$,replace$)
if lfpos<1 then goto NEXTN
if lfpos=1 then l$=chr$(39)+l$:goto DUMP
if lfpos>1 and lfpos<7 then goto NEXTN
if mid$(l$,lfpos-5,4)="GOTO"_
or mid$(l$,lfpos-5,4)="goto"_
or mid$(l$,lfpos-6,5)="GOSUB"_
or mid$(l$,lfpos-6,5)="gosub" then
gosub SPLIT
n=0
goto NEXTN
end if
NEXTN:
next n
goto DUMP
SPLIT:
lpart$=left$(l$,lfpos-2)
rpos=lfpos+len(replace$)-1
rpart$=right$(l$,len(l$)-rpos)
l$=lpart$+new$+rpart$
return
DUMP:
l$=str$(z*10)+chr$(32)+l$
print #2,l$
goto SEARCH
NOFIND:
print"ERROR: No file by that name found."
goto HELP
BADFILE:
print"ERROR: Duplicate or missing filename."
goto HELP
FINISH:
print " Finish time: ";time$
close
print"Would you like a list of replaced labels"
print"sent to your printer? ( Y or N ) "
IN: w$=inkey$:if w$="" then goto IN:
if w$="y" or w$="Y" then goto PRINTOUT
if w$="n" or w$="N" then end else goto IN
PRINTOUT:
print"Turn on your printer, please, and hit a key"
WAITING: w$=inkey$:if w$="" then goto WAITING
lprint"LINE","LABEL"
lprint""
for n = 1 to s
lprint subnum(n),subname$(n)
next n
lprint""
lprint s;"labels found in ";z;" program lines"
end