Difference between revisions of "EXECSCRIPT()"
From Lianjapedia
Yvonne.milne (Talk | contribs) (→Description) |
|||
(8 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
==Purpose== | ==Purpose== | ||
Function to run multiple lines of code | Function to run multiple lines of code | ||
− | |||
==Syntax== | ==Syntax== | ||
− | EXECSCRIPT(< | + | EXECSCRIPT(<expC> [, <param1> [, ... <paramN>]]) |
− | + | ||
==See Also== | ==See Also== | ||
− | [[COMPILE]], [[EXEC()]], [[ | + | [[COMPILE]], [[EXEC()]], [[EXECJAVASCRIPT()]], [[EXECPHP()]], [[EXECPYTHON()]] |
− | + | ||
==Description== | ==Description== | ||
− | The EXECSCRIPT() function runs multiple lines of code. The lines of code are contained in <expC>, which can be a text constant, a character variable, or a character or memo field. The EXECSCRIPT() function, unlike EXEC() can handle blocks of code, such as FOR...NEXT or DO WHILE...ENDDO loops. Individual lines of code must be separated by a CHR( | + | The EXECSCRIPT() function runs multiple lines of code. The lines of code are contained in <expC>, which can be a text constant, a character variable, or a character or memo field. The EXECSCRIPT() function, unlike EXEC() can handle blocks of code, such as FOR...NEXT or DO WHILE...ENDDO loops. Individual lines of code must be separated by a CHR(10) line feed character. |
+ | |||
+ | If the first statement in <expC> is a [[PARAMETERS]] statement, a comma-separated list of parameters can be included. | ||
The EXECSCRIPT() function returns a logical true (.T.) unless its contents specifically return false (.F.). | The EXECSCRIPT() function returns a logical true (.T.) unless its contents specifically return false (.F.). | ||
− | |||
==Example== | ==Example== | ||
<code lang="recital"> | <code lang="recital"> | ||
// Character field | // Character field | ||
− | |||
− | |||
create table scripts (script char(200)) | create table scripts (script char(200)) | ||
use scripts | use scripts | ||
append blank | append blank | ||
− | replace script with "for i=1 to 10" + CHR( | + | replace script with "for i=1 to 10" + CHR(10) + "?i" + CHR(10) + "endfor" + CHR(10) |
execscript(script) | execscript(script) | ||
// Text constant | // Text constant | ||
− | execscript("for i=1 to 10" + CHR( | + | execscript("for i=1 to 10" + CHR(10) + "?i" + CHR(10) + "endfor" + CHR(10)) |
// Memory variable | // Memory variable | ||
− | m_script = " | + | m_script = "for i=1 to 10" + CHR(10) + "?i" + CHR(10) + "endfor" + CHR(10) |
− | + | ||
execscript(m_script) | execscript(m_script) | ||
− | |||
+ | // Including parameters | ||
+ | execscript("parameters p1,p2"+chr(10)+"messagebox(p1+etos(p2))"+chr(10),"Hello ",2013) | ||
+ | </code> | ||
− | |||
− | |||
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:Functions]] | [[Category:Functions]] | ||
[[Category:SQL]] | [[Category:SQL]] |
Latest revision as of 06:58, 18 January 2023
Contents
Purpose
Function to run multiple lines of code
Syntax
EXECSCRIPT(<expC> [, <param1> [, ... <paramN>]])
See Also
COMPILE, EXEC(), EXECJAVASCRIPT(), EXECPHP(), EXECPYTHON()
Description
The EXECSCRIPT() function runs multiple lines of code. The lines of code are contained in <expC>, which can be a text constant, a character variable, or a character or memo field. The EXECSCRIPT() function, unlike EXEC() can handle blocks of code, such as FOR...NEXT or DO WHILE...ENDDO loops. Individual lines of code must be separated by a CHR(10) line feed character.
If the first statement in <expC> is a PARAMETERS statement, a comma-separated list of parameters can be included.
The EXECSCRIPT() function returns a logical true (.T.) unless its contents specifically return false (.F.).
Example
// Character field create table scripts (script char(200)) use scripts append blank replace script with "for i=1 to 10" + CHR(10) + "?i" + CHR(10) + "endfor" + CHR(10) execscript(script) // Text constant execscript("for i=1 to 10" + CHR(10) + "?i" + CHR(10) + "endfor" + CHR(10)) // Memory variable m_script = "for i=1 to 10" + CHR(10) + "?i" + CHR(10) + "endfor" + CHR(10) execscript(m_script) // Including parameters execscript("parameters p1,p2"+chr(10)+"messagebox(p1+etos(p2))"+chr(10),"Hello ",2013)