Partager via


EXECSCRIPT( ) Function

Enables you to run multiple lines of code from variables, tables, and other text at runtime.

ExecScript(cExpression [, eParameter1, eParameter2, ...])

Parameters

  • cExpression
    Represents the text, a variable, type string, or memo to be executed as code.

  • eParameter1, eParameter2, ...
    Optional. Specify parameters passed to a script that has a parameter statement in first line.

Return Value

The return value is the value returned by the script in cExpression. If the script returns no value, Visual FoxPro returns .T.

Remarks

ExecScript( ), unlike macro expansion, provides the same effect as selecting several lines of code in the command window then pressing the Enter key.

Example

This example creates a form and then shows the value of the AutoCenter property of the new Form object. Note the use of CHR(13), which is used to separate the two code lines.

?EXECSCRIPT("oForm=CREATEOBJECT('Form')"+CHR(13)+"?oForm.AutoCenter")

See Also

Concepts

Handling Run-Time Errors

Reference

COMPILE Command

ON ERROR Command

Other Resources

Functions

Language Reference (Visual FoxPro)