Hi Rob,
Here is an example of dynamic compiling taken from OxygenBasic\examples\DynamicCompile\
This runs in JIT mode but I have encountered a problem when trying to run it as an EXE/DLL. In any case it requires Oxygen.dll to provide the run-time compiling.
You can of course, manipulate source code strings in thinBasic and do primary compiling in the usual way.
'-------------------------------------
'RUNTIME COMPILING FROM STRINGS
'WITH ACCESS TO ALL PARENTAL VARIABLES
'-------------------------------------
'-----------------------------------------------
function evaluate (string s,float b,e) as string
'===============================================
'
double x,y,z
sys a,p
string v,u,tab,cr,er
'
p=1
cr=chr(13,10)
tab=chr(9)
v=nuls 4000
mid v,p,s+cr+cr
p+=4+len s
'
a=compile s
er=error
if er then
print "runtime error: " er : exit function
end if
for x=b to e
call a
u=str(x) tab str(y) cr
mid v,p,u : p+=len u
next
'
freememory a
'
function=left v,p-1
'
end function
print evaluate "y=x*x*x",1,10
print evaluate "y=sqrt x",1,9
Bookmarks