Jump to content

Runtime evaluation: Difference between revisions

Added BBC BASIC
m (→‎{{header|REXX}}: added more whitespace, added a comment. -- ~~~~)
(Added BBC BASIC)
Line 110:
20 LOAD "PROG2"
</lang>
 
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
===Expressions===
Expressions can be evaluated using the EVAL function:
<lang bbcbasic> expr$ = "PI^2 + 1"
PRINT EVAL(expr$)</lang>
Output:
<pre>
10.8696044
</pre>
 
===Statements===
Statements can only be executed by being tokenised and then written to a temporary file:
<lang bbcbasic> exec$ = "PRINT ""Hello world!"""
bbc$ = FNtokenise(exec$)
tmpfile$ = @tmp$+"temp.bbc"
tmpfile% = OPENOUT(tmpfile$)
BPUT#tmpfile%, bbc$+CHR$0
CLOSE #tmpfile%
CALL tmpfile$
END
DEF FNtokenise(A$)
LOCAL A%
A% = EVAL("0:"+A$)
A$ = $(!332+2)
= CHR$(LENA$+4) + CHR$0 + CHR$0 + A$ + CHR$13
</lang>
Output:
<pre>
Hello world!
</pre>
 
=={{header|Common Lisp}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.