// FRB in-memory compilation test // Compiles PRG source at runtime and executes it FUNCTION Main() LOCAL pMod, cSource ? "=== FRB In-Memory Compilation Test ===" ? "" // 1. Compile PRG source string at runtime cSource := 'FUNCTION Double(n)' + Chr(10) + ; ' RETURN n * 2' + Chr(10) + ; 'FUNCTION Greet(cName)' + Chr(10) + ; ' RETURN "Hi " + cName + "!"' + Chr(10) ? "Compiling PRG source at runtime..." pMod := FrbCompile(cSource) IF pMod = NIL ? "ERROR: Compile failed" RETURN NIL ENDIF ? "Compiled!" ? "" // 2. Call dynamically compiled functions ? "Double(21):", FrbDo(pMod, "DOUBLE", 21) ? "Greet('Charles'):", FrbDo(pMod, "GREET", "Charles") ? "" FrbUnload(pMod) // 3. One-shot: compile + run + unload ? "FrbExec one-shot:" cSource := 'FUNCTION Main()' + Chr(10) + ; ' ? " Hello from dynamic PRG!"' + Chr(10) + ; ' RETURN 42' + Chr(10) ? "Result:", FrbExec(cSource) ? "" ? "=== Done ===" RETURN NIL