Well it doesn't really do anything yet, but you can set up data (I got it to work with variables, but it didn't work right, it basically treated the last created variable as the only one, which is fine if you want to create a variable everytime before you use it, but that was unorgnised)
Here's some code:
`Setup
sync on : sync rate 60
set display mode 1024,768,32
`Command Lines
lines=fileLines("zcode1.txt")
dim cmd(lines) as string
open to read 1,"zcode1.txt"
for l=1 to lines
read string 1,cmd(l)
next l
close file 1
`**Compile**
compl:
cls : ln=0
compileData(lines)
`**Compile**
`Main Loop
do
`Show data
for b=1 to 4 : for v=0 to 3
inc ln
if ln<=16
if v=0
text 10,ln*20,zobj(b,v)+":"
else
for in=1 to len(zobj(b,0))-3
in$=in$+" "
next in
text 10,ln*20,in$+zobj(b,v)
in$=""
endif
endif
next v : next b
`Restart
text 10,screen height()-30,"Press space to restart (and try to spot the random number!)"
if spacekey() then goto compl
sync
loop
`Functions - File
function fileLines(filename$)
open to read 1,filename$
repeat
read string 1,wasted$
inc lines
until file end(1)
close file 1
endfunction lines
`Functions - String
function getTokens(st$,sp$)
repeat
counter=counter+1
cur$=mid$(st$,counter)
if cur$=sp$ then inc splits
until counter>len(st$)
tokens=splits+1
endfunction tokens
function getToken(st$,sp$,num)
nst$=sp$+st$+sp$
repeat
inc counter
cur$=mid$(nst$,counter)
if cur$=sp$ then inc splits
until splits=num or counter>len(st$)
repeat
inc counter
cur$=mid$(nst$,counter)
if cur$<>sp$ then token$=token$+cur$
until cur$=sp$ or counter>len(st$)
endfunction token$
function mid(st$,st,fn)
for s=st to st+fn
cur$=cur$+mid$(st$,s)
next s
endfunction cur$
function clumpmid(st$,st,fn)
for s=st to fn
cur$=cur$+mid$(st$,s)
next s
endfunction cur$
function linearSearch(st$,s$)
local pos as integer
local count as integer
local length as integer : length=len(s$)
repeat
count=count+1
if mid(st$,count,length)=s$
pos=count
endif
until pos>0
endfunction pos
function removeSpace(st$)
for s=1 to len(st$)
cur$=mid$(st$,s)
if cur$<>" " then new$=new$+cur$
next s
endfunction new$
`Functions - Compile
function compileData(commands)
local curCom as string
dim value(commands,commands) as float
dim secvalues(commands) as integer
dim cmdType(commands) as string
dim zobj(commands,commands) as string
`Select all lines
for c=1 to commands
`Shorten Command
curCom=removeSpace(left$(cmd(c),len(cmd(c))))
`Braces
if right$(curCom,1)="{"
inc obrace
zobj(obrace,0)=left$(curCom,len(curCom)-1)
endif
`Commands
`val(Value) Command
if left$(curCom,4)="val("
cmdType(c)="val"
endif
if cmdType(c)="val"
if mid$(curCom,len(curCom))=")"
secvalues(obrace)=secvalues(obrace)+1
value(obrace,secvalues(obrace))=val(clumpmid(curCom,5,len(curCom)-1))
endif
zobj(obrace,secvalues(obrace))=str$(value(obrace,secvalues(obrace)))
endif
`rnd(Value) Command
if left$(curCom,4)="rnd("
cmdType(c)="rnd"
endif
if cmdType(c)="rnd"
if mid$(curCom,len(curCom))=")"
secvalues(obrace)=secvalues(obrace)+1
value(obrace,secvalues(obrace))=rnd(val(clumpmid(curCom,5,len(curCom)-1)))
endif
zobj(obrace,secvalues(obrace))=str$(value(obrace,secvalues(obrace)))
endif
`add(Value1,value2) Command
if left$(curCom,4)="add("
cmdType(c)="add"
endif
if cmdType(c)="add"
if mid$(curCom,len(curCom))=")"
secvalues(obrace)=secvalues(obrace)+1
addval1#=val(getToken(clumpmid(curCom,5,len(curCom)-1),",",1))
addval2#=val(getToken(clumpmid(curCom,5,len(curCom)-1),",",2))
value(obrace,secvalues(obrace))=addval1#+addval2#
endif
zobj(obrace,secvalues(obrace))=str$(value(obrace,secvalues(obrace)))
endif
`sub(Value1,value2) Command
if left$(curCom,4)="sub("
cmdType(c)="sub"
endif
if cmdType(c)="sub"
if mid$(curCom,len(curCom))=")"
secvalues(obrace)=secvalues(obrace)+1
subval1#=val(getToken(clumpmid(curCom,5,len(curCom)-1),",",1))
subval2#=val(getToken(clumpmid(curCom,5,len(curCom)-1),",",2))
value(obrace,secvalues(obrace))=subval1#-subval2#
endif
zobj(obrace,secvalues(obrace))=str$(value(obrace,secvalues(obrace)))
endif
`Mlt(Value1,Value2) Command
if left$(curCom,4)="mlt("
cmdType(c)="mlt"
endif
if cmdType(c)="mlt"
if mid$(curCom,len(curCom))=")"
if getTokens(curCom,",")
secvalues(obrace)=secvalues(obrace)+1
value(obrace,secvalues(obrace))=val(getToken(clumpmid(curCom,5,len(curCom)-1),",",1))*val(getToken(clumpmid(curCom,5,len(curCom)-1),",",2) )
endif
endif
zobj(obrace,secvalues(obrace))=str$(value(obrace,secvalues(obrace)))
endif
`Div(Value1,Value2) Command
if left$(curCom,4)="div("
cmdType(c)="div"
endif
if cmdType(c)="div"
if mid$(curCom,len(curCom))=")"
if getTokens(curCom,",")
secvalues(obrace)=secvalues(obrace)+1
value(obrace,secvalues(obrace))=val(getToken(clumpmid(curCom,5,len(curCom)-1),",",1))/val(getToken(clumpmid(curCom,5,len(curCom)-1),",",2) )
endif
endif
zobj(obrace,secvalues(obrace))=str$(value(obrace,secvalues(obrace)))
endif
`Sin(Value) Command
if left$(curCom,4)="sin("
cmdType(c)="sin"
endif
if cmdType(c)="sin"
if mid$(curCom,len(curCom))=")"
secvalues(obrace)=secvalues(obrace)+1
value(obrace,secvalues(obrace))=sin(val(clumpmid(curCom,5,len(curCom)-1)))
endif
zobj(obrace,secvalues(obrace))=str$(value(obrace,secvalues(obrace)))
endif
`Cos(Value) Command
if left$(curCom,4)="cos("
cmdType(c)="cos"
endif
if cmdType(c)="cos"
if mid$(curCom,len(curCom))=")"
secvalues(obrace)=secvalues(obrace)+1
value(obrace,secvalues(obrace))=cos(val(clumpmid(curCom,5,len(curCom)-1)))
endif
zobj(obrace,secvalues(obrace))=str$(value(obrace,secvalues(obrace)))
endif
`Tan(Value) Command
if left$(curCom,4)="tan("
cmdType(c)="tan"
endif
if cmdType(c)="tan"
if mid$(curCom,len(curCom))=")"
secvalues(obrace)=secvalues(obrace)+1
value(obrace,secvalues(obrace))=tan(val(clumpmid(curCom,5,len(curCom)-1)))
endif
zobj(obrace,secvalues(obrace))=str$(value(obrace,secvalues(obrace)))
endif
`wrp(Value) Command
if left$(curCom,4)="wrp("
cmdType(c)="wrp"
endif
if cmdType(c)="wrp"
if mid$(curCom,len(curCom))=")"
secvalues(obrace)=secvalues(obrace)+1
value(obrace,secvalues(obrace))=wrapvalue(val(clumpmid(curCom,5,len(curCom)-1)))
endif
zobj(obrace,secvalues(obrace))=str$(value(obrace,secvalues(obrace)))
endif
next c
undim cmdType()
undim secvalues()
undim value()
endfunction
That was DBPro code.. this is my code:
This_is_an_object{
add(90,3)
sub(3,2)
mlt(4,2)
}
It_contains_data{
val(33333)
div(7,2)
rnd(400)
}
I_couldn't_think_of_a_better_name{
sin(90)
cos(180)
tan(45)
}
But_I_think_this_one_will_do{
wrp(722)
val(3)
val(4.00)
}
Basically what it does:
It creates an "object" (A pile of data) that will soon be probably be able to be used on 3d objects, i.e. I could make an object act as a vector to position the 3d objects. But not right now.
You will notice commands such as val, rnd, add, sub, etc. They do what they look like, add() will add two number, mlt() will multiply the two numbers, val() is ust the number, but I stupidly made it only search for commands. Nevermind.
This is the output I get from that code:
This_is_an_object:
93
1
8
It_contains_data:
33333
3.5
242
I_couldn't_think_of_a_better_name:
1
-1
1
But_I_think_this_one_will_do:
2
3
4
Pointless I know it, but it could be the start of something good