diff options
Diffstat (limited to 'source/text/sbasic/shared/03090301.xhp')
-rw-r--r-- | source/text/sbasic/shared/03090301.xhp | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/source/text/sbasic/shared/03090301.xhp b/source/text/sbasic/shared/03090301.xhp index 7335110a23..b2331842bc 100644 --- a/source/text/sbasic/shared/03090301.xhp +++ b/source/text/sbasic/shared/03090301.xhp @@ -27,38 +27,40 @@ <body> - <section id="gosubreturn"> <bookmark xml-lang="en-US" branch="index" id="bm_id3147242"> <bookmark_value>GoSub...Return statement</bookmark_value> + <bookmark_value>label; in GoSub...Return statement</bookmark_value> </bookmark> - -<paragraph id="hd_id3147242" role="heading" level="1" xml-lang="en-US"><link href="text/sbasic/shared/03090301.xhp" name="GoSub...Return Statement">GoSub...Return Statement</link></paragraph> -<paragraph id="par_id3145316" role="paragraph" xml-lang="en-US">Calls a subroutine that is indicated by a label from a subroutine or a function. The statements following the label are executed until the next Return statement. Afterwards, the program continues with the statement that follows the <emph>GoSub </emph>statement.</paragraph> +<h1 id="hd_id3147242" xml-lang="en-US"><variable id="GoSubh1"><link href="text/sbasic/shared/03090301.xhp" name="GoSub...Return Statement">GoSub...Return Statement</link></variable></h1> + <paragraph id="par_id3145316" role="paragraph" xml-lang="en-US">Calls a subroutine that is indicated by a label inside a <literal>Sub</literal> or a <literal>Function</literal>. The statements following the label are executed until the next <literal>Return</literal> statement. Afterwards, the program continues with the statement that follows the <literal>GoSub</literal> statement.</paragraph> </section> -<paragraph id="hd_id3145609" role="heading" level="2" xml-lang="en-US">Syntax:</paragraph> +<embed href="text/sbasic/shared/00000003.xhp#functsyntax"/> +<bascode> +<paragraph id="par_id3145069" role="bascode" xml-lang="en-US">GoSub label[:]</paragraph> +</bascode> + +<embed href="text/sbasic/shared/00000003.xhp#functparameters"/> +<paragraph role="paragraph" id="par_id471588670859073"><emph>label: </emph>A line identifier indicating where to continue execution. The scope of a label in that of the routine it belongs to.</paragraph> +<paragraph id="par_id3147318" role="paragraph" xml-lang="en-US">The <literal>GoSub</literal> statement calls a local subroutine indicated by a label from within a subroutine or a function. The name of the label must end with a colon (":").</paragraph> <bascode> -<paragraph id="par_id3145069" role="bascode" xml-lang="en-US">see Parameters</paragraph> + <paragraph role="bascode" id="bas_id171588670446922" localize="false">Sub/Function foo</paragraph> + <paragraph role="bascode" id="bas_id411588670455217" xml-lang="en-US"> ' statements</paragraph> + <paragraph role="bascode" id="bas_id315886704565218" localize="false"> GoSub label</paragraph> + <paragraph role="bascode" id="bas_id421588670457589" xml-lang="en-US"> ' statements </paragraph> + <paragraph role="bascode" id="bas_id551588670457866" localize="false"> Exit Sub/Function</paragraph> + <paragraph role="bascode" id="bas_id721588670458055" localize="false">label:</paragraph> + <paragraph role="bascode" id="bas_id171588670458263" xml-lang="en-US"> ' statements </paragraph> + <paragraph role="bascode" id="bas_id881588670473041" localize="false"> Return</paragraph> + <paragraph role="bascode" id="bas_id661588670476240" localize="false">End Sub/Function</paragraph> </bascode> -<paragraph id="hd_id3147265" role="heading" level="2" xml-lang="en-US">Parameters:</paragraph> -<paragraph id="par_id3148664" role="paragraph" xml-lang="en-US">Sub/Function</paragraph> -<paragraph id="par_id3150400" role="paragraph" xml-lang="en-US">statement block</paragraph> -<paragraph id="par_id3154140" role="paragraph" xml-lang="en-US"> Label</paragraph> -<paragraph id="par_id3150869" role="paragraph" xml-lang="en-US">statement block</paragraph> -<paragraph id="par_id3154909" role="paragraph" xml-lang="en-US">GoSub Label</paragraph> -<paragraph id="par_id3153969" role="paragraph" xml-lang="en-US">Exit Sub/Function</paragraph> -<paragraph id="par_id3154685" role="paragraph" xml-lang="en-US">Label:</paragraph> -<paragraph id="par_id3145786" role="paragraph" xml-lang="en-US">statement block</paragraph> -<paragraph id="par_id3159252" role="paragraph" xml-lang="en-US">Return</paragraph> -<paragraph id="par_id3154321" role="paragraph" xml-lang="en-US">End Sub/Function</paragraph> -<paragraph id="par_id3147318" role="paragraph" xml-lang="en-US">The <emph>GoSub</emph> statement calls a local subroutine indicated by a label from within a subroutine or a function. The name of the label must end with a colon (":").</paragraph> <paragraph id="par_id3153190" role="warning" xml-lang="en-US">If the program encounters a Return statement not preceded by <emph>GoSub</emph>, $[officename] Basic returns an error message. Use <emph>Exit Sub</emph> or <emph>Exit Function</emph> to ensure that the program leaves a Sub or Function before reaching the next Return statement.</paragraph> <paragraph id="par_id3145799" role="paragraph" xml-lang="en-US">The following example demonstrates the use of <emph>GoSub</emph> and <emph>Return</emph>. By executing a program section twice, the program calculates the square root of two numbers that are entered by the user.</paragraph> -<paragraph id="hd_id3156284" role="heading" level="2" xml-lang="en-US">Example:</paragraph> +<embed href="text/sbasic/shared/00000003.xhp#functexample"/> <bascode> <paragraph id="par_idm1341591488" role="bascode" localize="false" xml-lang="en-US">Sub ExampleGoSub</paragraph> <paragraph id="par_idm1341590256" role="bascode" localize="false" xml-lang="en-US">Dim iInputa As Single</paragraph> @@ -78,6 +80,12 @@ <paragraph id="par_idm1341570912" role="bascode" localize="false" xml-lang="en-US"> Return</paragraph> <paragraph id="par_idm1341569680" role="bascode" localize="false" xml-lang="en-US">End Sub</paragraph> </bascode> + +<section id="relatedtopics"> + <embed href="text/sbasic/shared/03090302.xhp#GoToh1"/> + <embed href="text/sbasic/shared/03090303.xhp#OnGoSubGoToh1"/> +</section> + </body> </helpdocument>
\ No newline at end of file |