<doc>
	<legacy_id>2403</legacy_id>
	<name>do</name>
	<type>command</type>

	<syntax>
		<example>do <i>statementList</i> </example>
		<example>do <i>statementList</i> in <i>caller</i> </example>
		<example>do <i>statementList</i> as a<i>lternateLanguageName</i></example>
	</syntax>

	<synonyms>
	</synonyms>

	<summary><glossary tag="execute">Executes</glossary> a list of <glossary tag="statement">statements</glossary>.</summary>

	<examples>
<example>do "go next card"</example>
<example>do "put"  x  "into tNumberOfRecords"  x -- might become "put 3 into tNumberOfRecords"</example>
<example><p>do "select"  line 3 of field "Objects"</p></example>
<example>do field "Statements" as AppleScript</example>
	</examples>

	<history>
		<introduced version="1.0">Added.</introduced>
		<deprecated version=""></deprecated>
		<removed version=""></removed>
<changed version="6.0">6.0</changed>
<changed version="2.9">2.9</changed>
		<experimental version=""></experimental>
		<nonexperimental version=""></nonexperimental>
	</history>

	<objects>
	</objects>

	<platforms>
		<mac/>
		<windows/>
		<linux/>
		<ios/>
		<android/>
	</platforms>

	<classes>
		<desktop/>
		<server/>
		<web/>
		<mobile/>
	</classes>

	<security>
	</security>


	<classification>
		<category>Writing LiveCode</category>
		<category>Standalone Applications</category>
	</classification>

	<references>
		<function tag="alternateLanguages">alternateLanguages function</function>
		<command tag="call">call command</command>
		<command tag="debugDo">debugDo command</command>
		<command tag="local">local command</command>
		<command tag="breakpoint">breakpoint command</command>
		<keyword tag="message box">message box keyword</keyword>
		<keyword tag="as">as keyword</keyword>
	</references>

	<description>
	<overview>Use the <b>do</b> 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.</overview>

		<parameters>
  <parameter>
    <name>statementList</name>
    <description>A LiveCode statement, a container with one or more statements, or a string that evaluates to a statement.</description>
  </parameter>
  <parameter>
    <name>alternateLanguageName</name>
    <description>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.</description>
  </parameter>
  <parameter>
    <name>caller</name>
    <description>Has the effect of executing the statementList in the context of the handler.</description>
  </parameter>		</parameters>

	<value></value>
	<comments>Using the <b>do</b> <glossary tag="command">command</glossary> is slower than directly <glossary tag="execute">executing</glossary> the <glossary tag="command">commands</glossary>, because each <glossary tag="statement">statement</glossary> must be <glossary tag="compile">compiled</glossary> every time the <b>do</b> <glossary tag="command">command</glossary> is executed.<p></p><p>On Mac OS X systems, if you use the do as a<i>lternateLanguageName</i> form, any result returned by the script language is placed in the <function tag="result">result</function>.</p><p></p><p>On Windows systems, the <function tag="result">result</function> 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":</p><p></p><p>do "result = 1 + 1" as "vbscript"</p><p>answer the result</p><p></p><p></p><important>If using the do as <i>alternateLanguageName</i> form, any paths used in the <i>statementList</i> 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.</important><p></p><p>If you attempt to specify an <i>alternateLanguageName</i> on a <glossary tag="Unix">Unix</glossary> <glossary tag="Windows">system</glossary>, the <b>do</b> <glossary tag="command">command</glossary> is not executed, and the <function tag="result">result</function> is set to "alternate language not found".</p><p></p><p>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 <function tag="result">result</function> variable instead of using WScript.Echo.</p><p></p><p>To see how to create a numbered set of variables see the dictionary entry for the <command tag="local">local command</command>.</p><p></p><p></p><change><p>The <i>alternateLanguageName</i> option was introduced in version 1.1. In previous versions, it was not possible to include AppleScript or other <glossary tag="Open Scripting Architecture (OSA)">OSA</glossary> languages in a <glossary tag="LiveCode">LiveCode</glossary> <glossary tag="handler">handler</glossary>.</change><p></p><p>The ability to specify an <i>alternateLanguageName</i> on Windows systems was added in LiveCode 2.9.</p><p>&#9;</p><p>&#9;</p></comments>
	</description>
</doc>