Executes a list of statements.
do statementList in <caller>
do statementList as alternateLanguageName
do "go next card"
do "put " & x & " into tNumberOfRecords" x -- might become "put 3 into tNumberOfRecords"
do "select" & line 3 of field "Objects"
do field "Statements" as AppleScript
do "myfunction(myparam1,myparam2);" in browser
Use the do command to execute statements in a container, or to execute a statement that consists partly of a literal string and partly of a container or the return value from a function.
- statementList - A LiveCode statement, a container with one or more statements, or a string that evaluates to a statement.
- alternateLanguageName -
- On Mac OS and OS X systems, the alternateLanguageName is a script language (such as AppleScript) supported under the Open Scripting Architecture.
- On Windows systems, the alternateLanguageName is an "active scripting" language (such as VBScript) supported by the Windows Scripting Host. The available languages are returned by the alternateLanguages function. If you specify an alternateLanguageName, the statementList must be written in the specified language.
- caller - Has the effect of executing the statementList in the context of the handler.
Using the do command is slower than directly executing the commands, because each statement must be compiled every time the do command is executed.
On Mac OS X systems, if you use the do as alternateLanguageName form, any result returned by the script language is placed in the result.
On Windows systems, the result function will return the value of the global variable called "result" in the script that was executed (or empty if no such variable was defined). For example the following code will produce a dialog box containing "2":
do "result = 1 + 1" as "vbscript" answer the result
Important! If using the do as alternateLanguageName form, any paths used in the statementList must be in the native format of the current system. In particular this means that paths must be converted to Windows native format before use on Windows machines. In most cases this can be done by replacing slash with backslash in the path.
If you attempt to specify an alternateLanguageName on a Unix system, the do command is not executed, and the result is set to "alternate language not found".
Any scripts on Windows which contain references to WScript will fail to run as WScript objects do not exist in the LiveCode Environment. Return values should therefore be placed within the global result variable instead of using WScript.Echo.
To see how to create a numbered set of variables see the dictionary entry for the local command.