Difference between revisions of "EXECPYTHON()"
From Lianjapedia
Yvonne.milne (Talk | contribs) |
Yvonne.milne (Talk | contribs) |
||
Line 1: | Line 1: | ||
==Purpose== | ==Purpose== | ||
− | Function to run | + | Function to run Python code |
==Syntax== | ==Syntax== | ||
Line 9: | Line 9: | ||
==Description== | ==Description== | ||
− | The EXECPYTHON() function runs | + | The EXECPYTHON() function runs Python code. The lines of code are contained in <expC>, which can be a text constant, a filename, a character variable, or a character or memo field. The EXECPYTHON() function can handle blocks of code. Individual lines of code must be separated by a CHR(13) carriage return character. If a filename.py is specified it is loaded and executed. Inside the .py file, to return a value assign a result to returnvalue. |
==Example== | ==Example== |
Revision as of 10:02, 28 March 2017
Contents
Purpose
Function to run Python code
Syntax
EXECPYTHON(<expC>)
See Also
COMPILE, EXEC(), EXECJAVASCRIPT(), EXECPHP(), EXECSCRIPT()
Description
The EXECPYTHON() function runs Python code. The lines of code are contained in <expC>, which can be a text constant, a filename, a character variable, or a character or memo field. The EXECPYTHON() function can handle blocks of code. Individual lines of code must be separated by a CHR(13) carriage return character. If a filename.py is specified it is loaded and executed. Inside the .py file, to return a value assign a result to returnvalue.
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 i in range(9):' + CHR(13)+ '# process commands' + CHR(13) execpython(script) // Text constant execpython('for i in range(9):' + CHR(13) + '# process commands' + CHR(13)) // Memory variable m_script = 'for i in range(9):' + CHR(13) + '# process commands' + CHR(13) execpython(m_script)