It's DBPro. It's not a "proper" language as such it does not compile just interprets each line put in. Accepted commands are:
- DIM $varname AS [STRING / INTEGER / REAL]
- PRINT You text +$includedvar +$anothervar more text
- SHOW ALL VARS - dumps list of variables to screen for debugging
- $varname = [VALUE]
- rem COMMENT
- ` COMMENT
hide mouse
rem dim variable array
dim Integers(12200)
dim Reals#(12200)
dim Strings$(12200)
dim Defined(12200)
dim DefinedNames$(12200)
NumOfVars=0
sync off
do
rem Get code
input line$
line2$ = lower$(line$)
rem If commented, ignore
Comment = GetComment(line$)
rem Check if defining var
goSub DimVar
rem Check if assigning value to var
goSub CheckIfAssign
rem Check if printing
goSub CheckIfPrinting
rem Misc Commands
goSub MiscCommands
sync
loop
Rem *** Include File: VarToKey.dba ***
Rem Created: 18/11/2002 17:49:49
Rem Included in Project: C:\Program Files\Dark Basic Software\Dark Basic Professional\Projects\Dbasic\DBasic.dbpro
function NameToKey(name$)
for c = 1 to len(name$)
char$ = mid$(name$,c)
`print "Char is [";char$;"] - ASC is ";asc(char$)
if char$ <> " " then inc varkey,asc(char$)
next c
endfunction varkey
Rem *** Include File: GetComment.dba ***
Rem Created: 18/11/2002 17:52:19
Rem Included in Project: C:\Program Files\Dark Basic Software\Dark Basic Professional\Projects\Dbasic\DBasic.dbpro
Function getComment(line$)
line$ = lower$(line$)
if left$(line$,3) = "rem" then comment = 1
if left$(line$,1) = "`" then comment = 1
EndFunction comment
Rem *** Include File: DimVar.dba ***
Rem Created: 18/11/2002 18:08:12
Rem Included in Project: C:\Program Files\Dark Basic Software\Dark Basic Professional\Projects\Dbasic\DBasic.dbpro
DimVar:
if comment > 0 then return
If left$(line2$,4) = "dim "
Rem We have a DIM statement, now get requested type.
`root type
vartype = 33
If right$(line2$,10) = " as string" then vartype = 1 : after=10
If right$(line2$,8) = " as real" then vartype = 2 : after=8
If right$(line2$,11) = " as integer" then vartype = 3 : after=11
if vartype = 33 then Error(2)
rem Now get variable name
`>> Extract first bit (ie before name)
name$ = right$(line$,len(line$)-4)
`>> Extract 2nd bit (ie after name)
name$ = left$(name$,len(name$)-after)
rem now get VarKey
key = NameToKey(name$)
rem Now add to list of defined vars
Defined(key)= vartype
inc NumOfVars
DefinedNames$(NumOfVars) = name$
endif
return
Rem *** Include File: Error.dba ***
Rem Created: 18/11/2002 18:23:43
Rem Included in Project: C:\Program Files\Dark Basic Software\Dark Basic Professional\Projects\Dbasic\DBasic.dbpro
Function Error(num)
ink rgb(255,0,0),0
if num = 1 then error$ = "Error: Unknown command"
if num = 2 then error$ = "Error: Cannot define - unknown type"
if num = 3 then error$ = "Error: Variable not defined"
if num = 4 then error$ = "Error: Cannot assign value, variable type does not agree with assignment"
if num = 5 then error$ = "Error: Number has more than one decimal point"
print ""
print " >> ";error$
ink rgb(190,0,0),0
print "Press any key to exit"
sync
wait key
end
EndFunction
Rem *** Include File: AssignVar.dba ***
Rem Created: 18/11/2002 18:53:13
Rem Included in Project: C:\Program Files\Dark Basic Software\Dark Basic Professional\Projects\Dbasic\DBasic.dbpro
CheckIfAssign:
rem Check if a value is being assigned to a var.
if comment > 0 then return
If left$(line$,1) = "$"
rem Line starts with a $, so a var follows.
` >> Get position of "="
for c = 1 to len(line$)
char$ = mid$(line$,c)
if char$ = "=" then equals = c
next c
for c = len(line$) to 1 step -1
char$ = mid$(line$,c)
if char$ <> "=" and done=0 then inc equals_right
if char$ = "=" then done=1
next c
` >> We have position of equals, now get var name
var$ = left$(line$,equals-1)
` >> Now get key to name
key = NameToKey(var$)
` >> Now get type of var
vartype = Defined(key)
` >> If undefined var then error
If vartype = 0 then Error(3)
done=0
` >> Get assignment
assign$ = right$(line$,(len(line$)-equals))
` >> Check if vars are embedded in string and replace
if NumOfVars=0 then goto donecheck2
for v = 1 to NumOfVars
varname_r$ = DefinedNames$(v)
key_r = NameToKey(varname_r$)
vartype_r = Defined(key)
`>>> If var is a string
if vartype = 1
if vartype_r = 1 then rep$ = Strings$(key_r)
if vartype_r = 2 then rep$ = str$(Reals#(key_r))
if vartype_r = 3 then rep$ = str$(Integers(key_r))
endif
`>>> If var is a float or integer
if vartype = 2 or vartype = 3
if vartype_r = 1 then rep = val(Strings$(key_r))
if vartype_r = 2 then rep = Reals#(key_r)
if vartype_r = 3 then rep = Integers(key_r)
endif
print "Rep: ";rep$
print "Key: ";key_r
print "replacing var ";varname_r$;" of type ";vartype_r;" with ";rep$
if vartype = 2 or vartype = 3
assign$=Replacestr(assign$,varname_r$,str$(rep),1)
else
assign$=Replacestr(assign$,"+"+varname_r$,rep$,1)
endif
print "Finished. ";assign$
next v
donecheck2:
` >> If space at beginning then remove
if left$(assign$,1)=" " then assign$=right$(assign$,len(assign$)-1)
` print "Assignment:";assign$
` print "At equals:",mid$(line$,equals)
` print "At equals-r:",mid$(line$,(len(line$)-equals))
assigntype=0
do
rem Get type of assignment
` >> Check for String assignment
If mid$(line$,equals+1)="'" and right$(line$,1) = "'" then assigntype = 1 : exit
If left$(assign$,1)="'" then assigntype = 1 : exit
` >> Check for Real assignment
dpoints = 0
for c = 1 to len(assign$)
char$ = mid$(assign$,c)
if char$ = "." then inc dpoints
next c
` >> If more than one decimal point then error
If dpoints > 1 then Error(5)
if dpoints = 1 and assigntype=0
assigntype = 2 : exit
endif
` print "L:";left$(assign$,1)
if left$(assign$,1)="$" then assigntype=4 :exit
assigntype=3 : exit
loop
rem Strip ['] chars from string
If assigntype=1
assign$ = left$(assign$,len(assign$)-1)
assign$ = right$(assign$,len(assign$)-1)
Endif
`print left$(assign$,len(assign$)-1)
`print right$(assign$,len(assign$)-1)
` print assigntype
` print assign$
Rem Store assignment!
if vartype=1 then Strings$(key)=assign$ :` print var$;" has the value ";Strings$(key)
if vartype=2 then Reals#(key)=val(assign$) :` print var$;" has the value ";Reals#(key)
if vartype=3 then Integers(key)=val(assign$) :` print var$;" has the value ";Integers(key)
rem If assigning a var to a var, get var type + contents
if assigntype=4
key2 = NameToKey(assign$)
vartype2 = Defined(key)
rem if wrong type then error
if vartype2 <> vartype then Error(4)
if Vartype2=1 then assignedvar$=Strings$(key2)
if Vartype2=2 then assignedvar#=Reals#(key2)
if Vartype2=3 then assignedvar=Integers(key2)
if Vartype2 <> vartype then Error(4)
if vartype=1 then Strings$(key)=Strings$(key2) :` print var$;" has the value ";Strings$(key)
if vartype=2 then Reals#(key)=Reals#(key2) :` print var$;" has the value ";Reals#(key)
if vartype=3 then Integers(key)=Integers(key2) :` print var$;" has the value ";Integers(key)
endif
` print "VAR: ";vartype;" ASSIGN: ",assigntype
endif
return
Rem *** Include File: Print.dba ***
Rem Created: 21/11/2002 19:13:06
Rem Included in Project: C:\Program Files\Dark Basic Software\Dark Basic Professional\Projects\Dbasic\DBasic.dbpro
CheckIfPrinting:
if left$(line2$,6)="print "
toprint$ = right$(line$,len(line$)-6)
rem If we are printing a Var then get info and print
if mid$(line$,7)="$"
var$=right$(line$,len(line$)-6)
key = NameToKey(var$)
vartype = Defined(key)
If vartype = 1 then print Strings$(key)
If vartype = 2 then print Reals#(key)
If vartype = 3 then print Integers(key)
else
rem Check if vars are embedded in string
if NumOfVars=0 then goto donecheck
for v = 1 to NumOfVars
varname$ = DefinedNames$(v)
key = NameToKey(varname$)
vartype = Defined(key)
if vartype = 1 then rep$ = Strings$(key)
if vartype = 2 then rep$ = str$(Reals#(key))
if vartype = 3 then rep$ = str$(Integers(key))
toprint$=Replacestr(toprint$,"+"+varname$,rep$,1)
next v
donecheck:
print toprint$
endif
endif
return
Rem *** Include File: MiscCommands.dba ***
Rem Created: 22/11/2002 17:08:25
Rem Included in Project: C:\Program Files\Dark Basic Software\Dark Basic Professional\Projects\Dbasic\DBasic.dbpro
MiscCommands:
rem Dump of var names
if line2$ = "show all vars"
print "-------------------"
print " Variable dump "
print "-------------------"
if NumOfVars=0 then print "No variables have been defined." : return
print "Variables defined: ";NumOfVars
for v = 1 to NumOfVars
print DefinedNames$(v)
next v
print "-------------------"
endif
return
Rem *** Include File: Replacestr.dba ***
Rem Created: 22/11/2002 18:37:49
Rem Included in Project: C:\Program Files\Dark Basic Software\Dark Basic Professional\Projects\Dbasic\DBasic.dbpro
rem ---------------------------------------------------------------
function Instr(source$,check$,startpos,ignorecase)
rem --- Requires Midstr() function
if ignorecase = 0
`source$ = lower$(source$)
`check$ = lower$(check$)
endif
repeat
if Midstr(source$,startpos,len(check$)) = check$ then exitfunction startpos
inc startpos,1
until startpos > len(source$)
endfunction 0
rem ---------------------------------------------------------------
function Midstr(source$,pos,length)
t$ = left$(right$(source$,len(source$)-(pos-1)),length)
endfunction t$
rem ---------------------------------------------------------------
Function Replacestr(source$,check$,replace$,ignorecase)
rem --- requires Instr() and Midstr() functions
pos = 1
repeat
pos = Instr(source$,check$,pos,ignorecase)
if pos <> 0
source$ = left$(source$,pos-1) + replace$ + right$(source$,len(source$) - (pos + len(check$) - 1))
pos = pos + len(replace$)
endif
until pos = 0
endfunction source$
There's no place like 127.0.0.1
There are 10 people in this world, those who understand binary and those who don't.