Difference between revisions of "Server Side Procedures - Parameter Passing Examples"
From Lianjapedia
Yvonne.milne (Talk | contribs) |
Yvonne.milne (Talk | contribs) |
||
Line 49: | Line 49: | ||
var result = Lianja.evaluate("mylib::mylibproc('{num3}','{num4}')");</pre> | var result = Lianja.evaluate("mylib::mylibproc('{num3}','{num4}')");</pre> | ||
− | ===FORMAT()=== | + | ====FORMAT()==== |
Lianja v5.3 introduced the [[FORMAT()|format()]] function, which simplifies the preparation of Lianja.evaluate() call strings, e.g. | Lianja v5.3 introduced the [[FORMAT()|format()]] function, which simplifies the preparation of Lianja.evaluate() call strings, e.g. | ||
Latest revision as of 11:21, 13 February 2020
Contents
Overview
For an overview of using server side procedures with the Lianja Web Client and Lianja Cloud Server, see here.
Lianja/VFP Server Side Procedures
exports.conf
A function can be called directly if it is declared in exports.conf.
var result = mylibproc();
Lianja.evaluate()
The Lianja.evaluate() method can be used to call a Lianja/VFP function/procedure.
var result = Lianja.evaluate("myproc()");
To call a procedure in a library, prefix the procedure name with the library name and '::'.
var result = Lianja.evaluate("mylib::mylibproc()");
Note how to build up the string passed to Lianja.evaluate() when using local variables:
Numeric variables:
var num5 = 5; var num6 = 7; var result = Lianja.evaluate("mylib::mylibproc(" + num5 + "," + num6 + ")");
String variables (include quotes):
var num7 = "5"; var num8 = "7"; var result = Lianja.evaluate("mylib::mylibproc('" + num7 + "','" + num8 + "')");
Macro substitution with {} can be used on globals in the Web Client:
Numeric:
num1 = 5; num2 = 7; var result = Lianja.evaluate("mylib::mylibproc({num1},{num2})");
Strings (include quotes):
num3 = "5"; num4 = "7"; var result = Lianja.evaluate("mylib::mylibproc('{num3}','{num4}')");
FORMAT()
Lianja v5.3 introduced the format() function, which simplifies the preparation of Lianja.evaluate() call strings, e.g.
//////////////////////////////////////////////////////////////// // Event delegate for 'customsectionmenu' event function page1_section1_customsectionmenu() { var cnum1 = "5"; var cnum2 = "7"; // Pass as character values for the mylibproc() function in the mylib.prg server-side procedure library var evalstring = format("mylib::mylibproc('{0}','{1}')",cnum1,cnum2); var result = Lianja.evaluate(evalstring); field1.text = field1.text + "\n" + result; var num1 = 5; var num2 = 7; // Pass as numeric values for the mylibproc() function in the mylib.prg server-side procedure library var evalstring = format("mylib::mylibproc({0},{1})",num1,num2); var result = Lianja.evaluate(evalstring); field1.text = field1.text + "\n" + result; };