Jump to content

Runtime evaluation: Difference between revisions

m (→‎{{header|REXX}}: removed superflous blanks. -- ~~~~)
Line 382:
</lang>
Executes the LOOP instruction, displaying the contents of the array pointed to by variable A.
 
=={{header|OxygenBasic}}==
Runtime (secondary) compiling is possible, with some restrictions. For instance static variables may not be created by the compiled code, but parental variables are visible to it. This demo produces tables of Y values, given a formula, and a range of X values to step through.
 
<lang oxygenbasic>
 
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
 
</lang>
 
=={{header|Oz}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.