<doc>
  <legacy_id>2341</legacy_id>
  <name>sysError</name>
  <type>function</type>
  <syntax>
    <example>the sysError</example>
    <example>sysError()</example>
  </syntax>
  <library></library>
  <objects>
  </objects>
  <synonyms>
  </synonyms>
  <classification>
    <category>The System Environment</category>
  </classification>
  <references>
    <command tag="kill">kill Command</command>
    <command tag="close file">close file Command</command>
    <function tag="result">result Function</function>
  </references>
  <history>
    <introduced version="1.0">Added.</introduced>
  </history>
  <platforms>
    <mac/>
    <windows/>
    <linux/>
  </platforms>
  <classes>
    <desktop/>
    <server/>
    <web/>
  </classes>
  <security>
  </security>
  <summary><glossary tag="return">Returns</glossary> the operating system's error status.</summary>
  <examples>
    <example>the sysError</example>
    <example>if the sysError is zero then answer "Success!"</example>
  </examples>
  <description>
    <p>Use the <b>sysError</b> <control_st tag="function">function</control_st> to obtain the reason a <glossary tag="command">command</glossary> that makes an operating-system request failed.</p><p/><p><b>Value:</b></p><p>The <b>sysError</b> <control_st tag="function">function</control_st> <glossary tag="return">returns</glossary> an <keyword tag="integer">integer</keyword>.</p><p/><p><b>Comments:</b></p><p>Most operating system requests have to do with actions on files. For example, when you open a file or copy a resource, LiveCode requests the operating system to complete the action. If the action fails, the <b>result</b> is set to an error message, and the <b>sysError</b> <control_st tag="function">function</control_st> contains the <href tag="../dictionary/error_message.xml">error message</href> the operating system reported to LiveCode.</p><p/><p>On Unix systems, the <b>sysError</b> function <glossary tag="return">returns</glossary> the <function tag="value">value</function> of the "errno" <glossary tag="variable">variable</glossary>.</p><p/><p>On Windows systems, the <b>sysError</b> function <glossary tag="return">returns</glossary> the <function tag="value">value</function> returned by the "GetLastError()" <control_st tag="function">function</control_st>.</p><p/><p><code/><b>Note:</b><code/> When using the <function tag="sysError">sysError</function> <control_st tag="function">function</control_st> to check whether a <glossary tag="command">command</glossary> succeeded, be sure to check the <function tag="result">result</function> first. The <b>sysError</b> reports the operating system's error report, and some operating-system commands may report a value (and therefore set the <b>sysError</b>) even if the command succeeded. Only if the <function tag="result">result</function> is not empty does the <b>sysError</b> indicate that the command failed.</p>
  </description>
</doc>