RosettaCodeData/Task/Runtime-evaluation/OxygenBasic/runtime-evaluation.oxy

51 lines
852 B
Plaintext

function ExecSeries(string s,double b,e,i) as string
'===================================================
'
sys a,p
string v,u,tab,cr,er
'
'PREPARE OUTPUT BUFFER
'
p=1
cr=chr(13) chr(10)
tab=chr(9)
v=nuls 4096
mid v,p,s+cr+cr
p+=4+len s
'
double x,y,z 'shared variables
'
'COMPILE
'
a=compile s
er=error
if er then
print "runtime error: " er : exit function
end if
'
'EXECUTE
'
for x=b to e step i
if p+128>=len v then
v+=nuls len(v) 'extend buffer
end if
call a
u=str(x) tab str(y) cr
mid v,p,u : p+=len u
next
'
freememory a 'release compiled code
'
return left v,p-1 'results
'
end function
'=====
'TESTS
'=====
'Expression, StartVal, EndVal stepVal, Increment
print ExecSeries "y=x*x*x", 1, 10, 1
print ExecSeries "y=sqrt x",1, 9 , 1