<doc>
	<legacy_id>2186</legacy_id>
	<name>result</name>
	<type>function</type>

	<syntax>
		<example>the result</example>
		<example>result()</example>
	</syntax>

	<synonyms>
	</synonyms>

	<summary>Is a global property returning the last value returned by return from a handler, from an engine function, or from an engine command which sets the result.</summary>

	<examples>
<example>the result</example>
<example>if the result is not empty then exit mouseUp</example>
	</examples>

	<history>
		<introduced version="1.0">Added.</introduced>
		<deprecated version=""></deprecated>
		<removed version=""></removed>
		
		<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>
	</classification>

	<references>
		<function tag="sysError">sysError Function</function>
		<keyword tag="catch">catch Keyword</keyword>
		<control_st tag="on">on Control Structure</control_st>
		<control_st tag="return">return Control Structure</control_st>
	</references>

	<description>Use the <b>result</b> <control_st tag="function">function</control_st> to check whether the last <glossary tag="command">command</glossary> <glossary tag="execute">executed</glossary> encountered an <glossary tag="error">error</glossary>, or get the last value returned with the control structure <control_st tag="return">return</control_st>.<p></p><p><b>Value:</b></p><p>The <b>result</b> <control_st tag="function">function</control_st> <glossary tag="return">returns</glossary> a <keyword tag="string">string</keyword>.</p><p></p><p><b>Comments:</b></p><p>Many commands (such as <b>go</b> and <command tag="find">find</command>) set the <function tag="value">value</function> of the <b>result</b> <control_st tag="function">function</control_st> when they finish. In most cases, if the <b>result</b> is empty, the <glossary tag="command">command</glossary> was successful; if the <b>result</b> is not empty, the <glossary tag="command">command</glossary> failed and the <b>result</b> contains an error message. See the specific <glossary tag="command">command</glossary> for information about whether it sets the <b>result</b> <control_st tag="function">function</control_st>.</p><p></p><p>If a command fails because of an operating-system error (such as a file not being available), the <b>sysError</b> <control_st tag="function">function</control_st> returns the error message that the operating system reported to LiveCode. In this case, you can use the <function tag="sysError">sysError</function> <control_st tag="function">function</control_st> to get additional information about the error if the <b>result</b> is not empty.</p><p></p><p>If the <b>return</b> <glossary tag="control structure">control structure</glossary> appears within an <control_st tag="on">on</control_st> <glossary tag="handler">handler</glossary>, the <b>result</b> <control_st tag="function">function</control_st> is set to the <glossary tag="return value">return value</glossary>. If a <glossary tag="handler">handler</glossary> contains the lines</p><p></p><p></p><p>and the "myMessage" handler contains the line</p><p></p><p>the text "some value" appears in the message box when the handler runs. You can use this capability to return an error message if a custom message handler fails.</p><p></p><p>The <b>result</b> <control_st tag="function">function</control_st> is set to empty when the current <glossary tag="handler">handler</glossary> finishes <glossary tag="execute">executing</glossary>.</p><p></p><p></p><p></p><p></p><important>If you need to check the <b>result</b>, do so immediately after the <glossary tag="statement">statement</glossary> whose result you want to check (or save the <function tag="value">value</function> of the <b>result</b> in a <glossary tag="variable">variable</glossary> for later checking). This ensures that the result you are checking is the correct one, not a value set by a later <glossary tag="statement">statement</glossary>.</important></description>
</doc>