EXECJAVASCRIPT()

From Lianjapedia
Revision as of 09:10, 9 January 2013 by Yvonne.milne (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Purpose

Function to run multiple lines of JavaScript code

Syntax

EXECJAVASCRIPT(<expC>)

See Also

COMPILE, EXEC(), EXECPHP(), EXECPYTHON(), EXECSCRIPT()

Description

The EXECJAVASCRIPT() function runs multiple lines of JavaScript 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 EXECJAVASCRIPT() function, can handle blocks of code, such as FOR and IF. Individual lines of code must be separated by a CHR(13) carriage return character.

Example

// Character field
create table if not exists scripts (script char(200))
if not used("scripts")
	use scripts
endif
select scripts
append blank
replace script with 'for (var i=0; i<11; i++)' + CHR(13) + '{';
 + CHR(13) + 'print("The number is " + i + "\n");' + CHR(13) + '}' + CHR(13)
execjavascript(script)
 
// Text constant
execjavascript('for (var i=0; i<11; i++)' + CHR(13) + '{';
 + CHR(13) + 'print("The number is " + i + "\n");' + CHR(13) + '}' + CHR(13))
 
// Memory variable
m_script = 'for (var i=0; i<11; i++)' + CHR(13) + '{';
 + CHR(13) + 'print("The number is " + i + "\n");' + CHR(13) + '}' + CHR(13)
execjavascript(m_script)