xref: /trunk/main/helpcontent2/source/text/sbasic/shared/03090412.xhp (revision 33101c50a61fbe5f636fda8537693c90fc0ad67c)
1cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?>
2cdf0e10cSrcweir
3226a8927SAndrew Rist<!--***********************************************************
4cdf0e10cSrcweir *
5226a8927SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
6226a8927SAndrew Rist * or more contributor license agreements.  See the NOTICE file
7226a8927SAndrew Rist * distributed with this work for additional information
8226a8927SAndrew Rist * regarding copyright ownership.  The ASF licenses this file
9226a8927SAndrew Rist * to you under the Apache License, Version 2.0 (the
10226a8927SAndrew Rist * "License"); you may not use this file except in compliance
11226a8927SAndrew Rist * with the License.  You may obtain a copy of the License at
12cdf0e10cSrcweir *
13226a8927SAndrew Rist *   http://www.apache.org/licenses/LICENSE-2.0
14cdf0e10cSrcweir *
15226a8927SAndrew Rist * Unless required by applicable law or agreed to in writing,
16226a8927SAndrew Rist * software distributed under the License is distributed on an
17226a8927SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18226a8927SAndrew Rist * KIND, either express or implied.  See the License for the
19226a8927SAndrew Rist * specific language governing permissions and limitations
20226a8927SAndrew Rist * under the License.
21cdf0e10cSrcweir *
22226a8927SAndrew Rist ***********************************************************-->
23226a8927SAndrew Rist
24cdf0e10cSrcweir<helpdocument version="1.0">
25cdf0e10cSrcweir<meta>
26cdf0e10cSrcweir<topic id="textsbasicshared03090412xml" indexer="include" status="PUBLISH">
27cdf0e10cSrcweir<title id="tit" xml-lang="en-US">Exit Statement [Runtime]</title>
28cdf0e10cSrcweir<filename>/text/sbasic/shared/03090412.xhp</filename>
29cdf0e10cSrcweir</topic>
30cdf0e10cSrcweir</meta>
31cdf0e10cSrcweir<body>
32cdf0e10cSrcweir<section id="exit">
33cd3ec106Smseidel<bookmark xml-lang="en-US" branch="index" id="bm_id3152924">
34cd3ec106Smseidel<bookmark_value>Exit statement</bookmark_value>
35cdf0e10cSrcweir</bookmark>
36*33101c50Smseidel<paragraph role="heading" id="hd_id3152924" xml-lang="en-US" level="1" l10n="U"><link href="text/sbasic/shared/03090412.xhp" name="Exit Statement [Runtime]">Exit Statement [Runtime]</link></paragraph>
37*33101c50Smseidel<paragraph role="paragraph" id="par_id3153394" xml-lang="en-US" l10n="U">Exits a <emph>Do...Loop</emph>, <emph>For...Next</emph>, a function, or a subroutine.</paragraph>
38cdf0e10cSrcweir</section>
39*33101c50Smseidel<paragraph role="heading" id="hd_id3149763" xml-lang="en-US" level="2" l10n="U">Syntax:</paragraph>
40*33101c50Smseidel<paragraph role="paragraph" id="par_id3159157" xml-lang="en-US" l10n="U">see Parameters</paragraph>
41*33101c50Smseidel<paragraph role="heading" id="hd_id3148943" xml-lang="en-US" level="2" l10n="U">Parameters:</paragraph>
42*33101c50Smseidel<paragraph role="paragraph" id="par_id3154760" xml-lang="en-US" l10n="U"><emph>Exit Do</emph></paragraph>
43*33101c50Smseidel<paragraph role="paragraph" id="par_id3147559" xml-lang="en-US" l10n="U">Only valid within a <emph>Do...Loop</emph> statement to exit the loop. Program execution continues with the statement that follows the Loop statement. If <emph>Do...Loop</emph> statements are nested, the control is transferred to the loop in the next higher level.</paragraph>
44*33101c50Smseidel<paragraph role="paragraph" id="par_id3150398" xml-lang="en-US" l10n="U"><emph>Exit For</emph></paragraph>
45*33101c50Smseidel<paragraph role="paragraph" id="par_id3148797" xml-lang="en-US" l10n="U">Only valid within a <emph>For...Next</emph> loop to exit the loop. Program execution continues with the first statement that follows the <emph>Next</emph> statement. In nested statements, the control is transferred to the loop in the next higher level.</paragraph>
46*33101c50Smseidel<paragraph role="paragraph" id="par_id3147229" xml-lang="en-US" l10n="U"><emph>Exit Function</emph></paragraph>
47*33101c50Smseidel<paragraph role="paragraph" id="par_id3154685" xml-lang="en-US" l10n="U">Exits the <emph>Function</emph> procedure immediately. Program execution continues with the statement that follows the <emph>Function</emph> call.</paragraph>
48*33101c50Smseidel<paragraph role="paragraph" id="par_id3155132" xml-lang="en-US" l10n="U"><emph>Exit Sub</emph></paragraph>
49*33101c50Smseidel<paragraph role="paragraph" id="par_id3149561" xml-lang="en-US" l10n="U">Exits the subroutine immediately. Program execution continues with the statement that follows the <emph>Sub</emph> call.</paragraph>
50*33101c50Smseidel<paragraph role="note" id="par_id3153143" xml-lang="en-US" l10n="U">The Exit statement does not define the end of a structure, and must not be confused with the End statement.</paragraph>
51*33101c50Smseidel<paragraph role="heading" id="hd_id3147348" xml-lang="en-US" level="2" l10n="U">Example:</paragraph>
52*33101c50Smseidel<paragraph role="paragraph" id="par_id3151113" xml-lang="en-US" l10n="U">Sub ExampleExit</paragraph>
53*33101c50Smseidel<paragraph role="paragraph" id="par_id3156283" xml-lang="en-US" l10n="U">Dim sReturn As String</paragraph>
54*33101c50Smseidel<paragraph role="paragraph" id="par_id3147125" xml-lang="en-US" l10n="U">Dim sListArray(10) as String</paragraph>
55*33101c50Smseidel<paragraph role="paragraph" id="par_id3151073" xml-lang="en-US" l10n="U">Dim siStep as Single</paragraph>
56*33101c50Smseidel<paragraph role="paragraph" id="par_id3153158" xml-lang="en-US" l10n="U">For siStep = 0 to 10 REM Fill array with test data</paragraph>
57*33101c50Smseidel<paragraph role="paragraph" id="par_id3148457" xml-lang="en-US" l10n="U">sListArray(siStep) = chr(siStep + 65)</paragraph>
58*33101c50Smseidel<paragraph role="paragraph" id="par_id3154492" xml-lang="en-US" l10n="U">msgbox sListArray(siStep)</paragraph>
59*33101c50Smseidel<paragraph role="paragraph" id="par_id3154791" xml-lang="en-US" l10n="U">next siStep</paragraph>
60*33101c50Smseidel<paragraph role="paragraph" id="par_id3153510" xml-lang="en-US" l10n="U">sReturn = LinSearch(sListArray(), "B")</paragraph>
61*33101c50Smseidel<paragraph role="paragraph" id="par_id3154513" xml-lang="en-US" l10n="U">Print sReturn</paragraph>
62*33101c50Smseidel<paragraph role="paragraph" id="par_id3149121" xml-lang="en-US" l10n="U">end sub</paragraph>
63*33101c50Smseidel<paragraph role="paragraph" id="par_id3152962" xml-lang="en-US" l10n="U">Function LinSearch( sList(), sItem As String ) as integer</paragraph>
64*33101c50Smseidel<paragraph role="paragraph" id="par_id3154755" xml-lang="en-US" l10n="U">dim iCount as Integer</paragraph>
65*33101c50Smseidel<paragraph role="paragraph" id="par_id3153764" xml-lang="en-US" l10n="U">REM LinSearch searches a TextArray:sList() for a TextEntry:</paragraph>
66*33101c50Smseidel<paragraph role="paragraph" id="par_id3148995" xml-lang="en-US" l10n="U">REM Returns the index of the entry or 0 ( Null)</paragraph>
67*33101c50Smseidel<paragraph role="paragraph" id="par_id3156057" xml-lang="en-US" l10n="U">for iCount=1 to Ubound( sList() )</paragraph>
68*33101c50Smseidel<paragraph role="paragraph" id="par_id3159266" xml-lang="en-US" l10n="U">if sList( iCount ) = sItem then</paragraph>
69*33101c50Smseidel<paragraph role="paragraph" id="par_id3149567" xml-lang="en-US" l10n="U">Exit for REM sItem found</paragraph>
70*33101c50Smseidel<paragraph role="paragraph" id="par_id3147343" xml-lang="en-US" l10n="U">end if</paragraph>
71*33101c50Smseidel<paragraph role="paragraph" id="par_id3155174" xml-lang="en-US" l10n="U">next iCount</paragraph>
72*33101c50Smseidel<paragraph role="paragraph" id="par_id3146313" xml-lang="en-US" l10n="U">if iCount = Ubound( sList() ) then iCount = 0</paragraph>
73*33101c50Smseidel<paragraph role="paragraph" id="par_id3166448" xml-lang="en-US" l10n="U">LinSearch = iCount</paragraph>
74*33101c50Smseidel<paragraph role="paragraph" id="par_id3146916" xml-lang="en-US" l10n="U">end function</paragraph>
75cdf0e10cSrcweir</body>
76cdf0e10cSrcweir</helpdocument>
77