DescriptionRuntime Variable Runtime #Constant Runtime Procedure() declaration Runtime Enumeration declaration
For advanced programmers. Runtime is used to create runtime accessible list of programming objects like variables, constants and procedures. Once compiled a program doesn't have variable, constant or procedure label anymore as everything is converted into binary code. Runtime enforces the compiler to add an extra reference for a specific object to have it available trough the Runtime library. The objects can be manipulated using their string reference, even when the program is compiled.
To illustrate the use of Runtime: the Dialog library use it to access the event procedure associated to a gadget. The name of the procedure to use for the event handler is specified in the XML file (which is text format), and then the dialog library use GetRuntimeInteger() to resolve the procedure address at runtime. It's not needed to recompile the program to change it.
Another use would be adding a small realtime scripting language to the program, allowing easy modification of exposed variables, using runtime constants values. While it could be done manually by building a map of objects, the Runtime keyword allows to do it in a standard and unified way.
Runtime Procedure OnEvent() Debug "OnEvent" EndProcedure Debug GetRuntimeInteger("OnEvent()") ; Will display the procedure address
Runtime Enumeration #Constant1 = 10 #Constant2 #Constant3 EndEnumeration Debug GetRuntimeInteger("#Constant1") Debug GetRuntimeInteger("#Constant2") Debug GetRuntimeInteger("#Constant3")
Define a = 20 Runtime a Debug GetRuntimeInteger("a") SetRuntimeInteger("a", 30) Debug a ; the variable has been modified
Example: Call a function by its name
Prototype Function() Runtime Procedure Function1() Debug "I call Function1 by its name" EndProcedure Runtime Procedure Function2() Debug "I call Function2 by its name" EndProcedure Procedure LaunchProcedure(Name.s) Protected ProcedureName.Function = GetRuntimeInteger(Name + "()") ProcedureName() EndProcedure LaunchProcedure("Function1") ; Display "I call Function1 by its name" LaunchProcedure("Function2") ; Display "I call Function2 by its name"