Runtime evaluation: Difference between revisions

added Liberty BASIC
(added Liberty BASIC)
Line 392:
 
J relies on the OS for sandboxing and does not offer any additional resource constraints.
 
=={{header|Liberty BASIC}}==
Liberty BASIC has the ability to evaluate arrays using a string for the array name and a variable for the element.
<lang lb>
'Dimension a numerical and string array
Dim myArray(5)
Dim myStringArray$(5)
 
'Fill both arrays with the appropriate data
For i = 0 To 5
myArray(i) = i
myStringArray$(i) = "String - " + str$(i)
Next i
 
'Set two variables with the names of each array
numArrayName$ = "myArray"
strArrayName$ = "myStringArray"
 
'Retrieve the array data by evaluating a string
'that correlates to the array
For i = 0 To 5
Print Eval$(numArrayName$ + "(" + str$(i) + ")")
Print Eval$(strArrayName$ + "$(" + str$(i) + ")")
Next i </lang>
 
An example using a struct and a pointer.
<lang lb>
Struct myStruct, value As long, _
string As ptr
myStruct.value.struct = 10
myStruct.string.struct = "Hello World!"
 
structName$ = "myStruct"
numElement$ = "value"
strElement$ = "string"
 
Print Eval$(structName$ + "." + numElement$ + "." + "struct")
 
'Pay close attention that this is EVAL() because we are
'retrieving the PTR to the string which is essentially a ulong
Print Winstring(Eval(structName$ + "." + strElement$ + "." + "struct")) </lang>
 
=={{header|Lua}}==
Anonymous user