LOCAL mVar, i FOR i = 1 to 10 mVar = "MEM" + PadL(Str(i), 2, "0") STORE i TO &mVar ENDFORX# still support this.
&& LOCAL oCB = { | [<paramList, ...>] | Comma separated list of Function/Procedures to be executed } -> Return last statement as return value. LOCAL oCB = { | cText | Hello(cText) } ? Eval(oCB, "Johan") && Hello Johan ? oCB:Eval("Joe Soap") && Hello Joe Soap, the OOP coding style with the same effect FUNCTION Hello(cTxt) RETURN "Hello " + cTxt ENDFUNCIt was even taken further which opened the door for creating Dynamic Applications by providing a Macro Compilation feature for codeblocks:
LOCAL cMath = "{ | a, b, c | b = a * 2, c = a + b }" LOCAL oMath = &cMath ? Eval(oMath, 2) && 6, a is here passed by value while b and c are used as "local" variables to the codeblock. LOCAL cHello = "{ | txt | StrTran(Lower(Hello(txt)), 'o', 'O') }" LOCAL oHello = &cHello ? Eval(oHello, "Johan") && hellO jOhan ? Eval(oHello, "ooooo") && hellO OOOOOSince this was also part of Visual Objects, it is also part of X#, however in VO one could only use "lazy" declared functions and procedures for macro-compilation. X# took it further and even .NET strict types can be used provided they are loaded before the MacroCompiler is loaded:
LOCAL cNet = "{ | a | System.Math.Multiply(a, 2) + a }" LOCAL oNet = &cNet oNet:MCompile(cNet) && This also works in the OOP syntax oNet = MCompile(cNet) && And if you rather want the XBase functional style ? oNet.Eval(2) && 6 is the answer again using OOP syntax ? Eval(oNet, 2) && And guess what the functional XBase works here too... with a surprise result of 6So we have a tool where we can save some of our code in a DBF or SQL database and don't need to recompile when we make changes to our application.