Difference between revisions of "EXECSCRIPT()"

From Lianjapedia
Jump to: navigation, search
Line 3: Line 3:
  
 
==Syntax==
 
==Syntax==
EXECSCRIPT(<expC>)
+
EXECSCRIPT(<expC> [, <param1> [, ... <paramN>]])
  
 
==See Also==
 
==See Also==
Line 10: Line 10:
 
==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(13) carriage return character.
 
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(13) carriage return 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.).
Line 28: Line 30:
 
m_script = "for i=1 to 10" + CHR(13) + "?i" + CHR(13) + "endfor" + CHR(13)  
 
m_script = "for i=1 to 10" + CHR(13) + "?i" + CHR(13) + "endfor" + CHR(13)  
 
execscript(m_script)
 
execscript(m_script)
 +
 +
// Including parameters
 +
execscript("parameters p1,p2"+chr(13)+"messagebox(p1+etos(p2))"+chr(13),"Hello ",2013)
 
</code>
 
</code>
  

Revision as of 12:03, 8 January 2013

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(13) carriage return 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(13) + "?i" + CHR(13) + "endfor" + CHR(13)
execscript(script)
 
// Text constant
execscript("for i=1 to 10" + CHR(13) + "?i" + CHR(13) + "endfor" + CHR(13))
 
// Memory variable
m_script = "for i=1 to 10" + CHR(13) + "?i" + CHR(13) + "endfor" + CHR(13) 
execscript(m_script)
 
// Including parameters
execscript("parameters p1,p2"+chr(13)+"messagebox(p1+etos(p2))"+chr(13),"Hello ",2013)