blob: 79078cc131c1fdb56515be9d9232909dcb579932 [file]
<?xml version="1.0" encoding="UTF-8"?>
<!--***********************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
***********************************************************-->
<helpdocument version="1.0">
<meta>
<topic id="textsbasicshared03050200xml" indexer="include" status="PUBLISH">
<title id="tit" xml-lang="en-US">Err Function [Runtime]</title>
<filename>/text/sbasic/shared/03050200.xhp</filename>
</topic>
</meta>
<body>
<section id="err">
<bookmark xml-lang="en-US" branch="index" id="bm_id3156343">
<bookmark_value>Err function</bookmark_value>
</bookmark>
<paragraph role="heading" id="hd_id3156343" xml-lang="en-US" level="1" l10n="U"><link href="text/sbasic/shared/03050200.xhp" name="Err Function [Runtime]">Err Function [Runtime]</link></paragraph>
<paragraph role="paragraph" id="par_id3150541" xml-lang="en-US" l10n="U">Returns an error code that identifies the error that occurred during program execution.</paragraph>
</section>
<paragraph role="heading" id="hd_id3149656" xml-lang="en-US" level="2" l10n="U">Syntax:</paragraph>
<paragraph role="paragraph" id="par_id3154123" xml-lang="en-US" l10n="U">Err</paragraph>
<paragraph role="heading" id="hd_id3147229" xml-lang="en-US" level="2" l10n="U">Return value:</paragraph>
<paragraph role="paragraph" id="par_id3150869" xml-lang="en-US" l10n="U">Integer</paragraph>
<paragraph role="heading" id="hd_id3153193" xml-lang="en-US" level="2" l10n="U">Parameters:</paragraph>
<paragraph role="paragraph" id="par_id3149561" xml-lang="en-US" l10n="U">The Err function is used in error-handling routines to determine the error and the corrective action.</paragraph>
<paragraph role="heading" id="hd_id3147317" xml-lang="en-US" level="2" l10n="U">Example:</paragraph>
<paragraph role="paragraph" id="par_id3153727" xml-lang="en-US" l10n="U">sub ExampleError</paragraph>
<paragraph role="paragraph" id="par_id3147426" xml-lang="en-US" l10n="U">on error goto ErrorHandler REM Set up error handler</paragraph>
<paragraph role="paragraph" id="par_id3163710" xml-lang="en-US" l10n="U">Dim iVar as Integer</paragraph>
<paragraph role="paragraph" id="par_id3153093" xml-lang="en-US" l10n="U">Dim sVar As String</paragraph>
<paragraph role="paragraph" id="par_id3149481" xml-lang="en-US" l10n="U">REM Error occurs due to non-existent file</paragraph>
<paragraph role="paragraph" id="par_id3153190" xml-lang="en-US" l10n="U">iVar = Freefile</paragraph>
<paragraph role="paragraph" id="par_id3146120" xml-lang="en-US" l10n="U">Open "\file9879.txt" for Input as #iVar</paragraph>
<paragraph role="paragraph" id="par_id3155308" xml-lang="en-US" l10n="U">Line Input #iVar, sVar</paragraph>
<paragraph role="paragraph" id="par_id3153142" xml-lang="en-US" l10n="U">Close #iVar</paragraph>
<paragraph role="paragraph" id="par_id3149665" xml-lang="en-US" l10n="U">exit sub</paragraph>
<paragraph role="paragraph" id="par_id3154942" xml-lang="en-US" l10n="U">ErrorHandler:</paragraph>
<paragraph role="paragraph" id="par_id3145646" xml-lang="en-US" l10n="U">MsgBox "Error " &amp; Err &amp; ": " &amp; Error$ + chr(13) + "At line : " + Erl + chr(13) + Now , 16 ,"an error occurred"</paragraph>
<paragraph role="paragraph" id="par_id3155418" xml-lang="en-US" l10n="U">end sub</paragraph>
</body>
</helpdocument>