diff options
-rw-r--r-- | Package_html_media.mk | 3 | ||||
-rw-r--r-- | source/media/helpimg/sbasic/For-Each_statement.svg | 43 | ||||
-rw-r--r-- | source/media/helpimg/sbasic/For-Next_statement.svg | 52 | ||||
-rw-r--r-- | source/media/helpimg/sbasic/On-Error_statement.svg | 45 | ||||
-rw-r--r-- | source/text/sbasic/shared/03050500.xhp | 3 | ||||
-rw-r--r-- | source/text/sbasic/shared/03090202.xhp | 127 |
6 files changed, 219 insertions, 54 deletions
diff --git a/Package_html_media.mk b/Package_html_media.mk index 2b5ab40425..a31efd6418 100644 --- a/Package_html_media.mk +++ b/Package_html_media.mk @@ -108,7 +108,10 @@ $(eval $(call gb_Package_add_files_with_dir,helpcontent2_html_media,$(LIBO_SHARE helpimg/smzb8.png \ helpimg/smzb9.png \ helpimg/sbasic/Call_statement.svg \ + helpimg/sbasic/For-Each_statement.svg \ + helpimg/sbasic/For-Next_statement.svg \ helpimg/sbasic/LetSet_statement.svg \ + helpimg/sbasic/On-Error_statement.svg \ helpimg/sbasic/Resume_statement.svg \ helpimg/scalc/coordinates-to-polar-01.svg \ helpimg/starmath/harpoon.svg \ diff --git a/source/media/helpimg/sbasic/For-Each_statement.svg b/source/media/helpimg/sbasic/For-Each_statement.svg new file mode 100644 index 0000000000..f12e794fa9 --- /dev/null +++ b/source/media/helpimg/sbasic/For-Each_statement.svg @@ -0,0 +1,43 @@ +<svg class="railroad-diagram" height="124" viewBox="0 0 746.0 124" width="746.0" xmlns="http://www.w3.org/2000/svg"> +<g transform="translate(.5 .5)"> +<style>/* <![CDATA[ */ + svg.railroad-diagram { + background-color:transparent; + } + svg.railroad-diagram path { + stroke-width:1; + stroke:black; + fill:rgba(0,0,0,0); + } + svg.railroad-diagram text { + font:bold 14px monospace; + font-family: Verdana, sans-serif; + text-anchor:middle; + } + svg.railroad-diagram text.label{ + text-anchor:start; + } + svg.railroad-diagram text.comment{ + font:italic 12px monospace; + } + svg.railroad-diagram rect{ + stroke-width:1; + stroke:black; + fill:transparent; + } + +/* ]]> */ +</style><g> +<path d="M20 41v20m10 -20v20m-10 -10h20"></path></g><path d="M40 51h10"></path><g> +<path d="M50 51h0.0"></path><path d="M696.0 51h0.0"></path><g class="terminal"> +<path d="M50.0 51h0.0"></path><path d="M138.0 51h0.0"></path><rect height="22" rx="10" ry="10" width="88.0" x="50.0" y="40"></rect><text x="94.0" y="55">For Each</text></g><path d="M138.0 51h10"></path><path d="M148.0 51h10"></path><g class="terminal"> +<path d="M158.0 51h0.0"></path><path d="M212.0 51h0.0"></path><rect height="22" rx="10" ry="10" width="54.0" x="158.0" y="40"></rect><text x="185.0" y="55">item</text></g><path d="M212.0 51h10"></path><path d="M222.0 51h10"></path><g class="terminal"> +<path d="M232.0 51h0.0"></path><path d="M269.0 51h0.0"></path><rect height="22" rx="10" ry="10" width="37.0" x="232.0" y="40"></rect><text x="250.5" y="55">In</text></g><path d="M269.0 51h10"></path><path d="M279.0 51h10"></path><g class="terminal"> +<path d="M289.0 51h0.0"></path><path d="M343.0 51h0.0"></path><rect height="22" rx="10" ry="10" width="54.0" x="289.0" y="40"></rect><text x="316.0" y="55">list</text></g><path d="M343.0 51h10"></path><path d="M353.0 51h10"></path><g> +<path d="M363.0 51h0.0"></path><path d="M498.0 51h0.0"></path><path d="M363.0 51h15"></path><g class="non-terminal"> +<path d="M378.0 51h0.0"></path><path d="M483.0 51h0.0"></path><rect height="22" width="105.0" x="378.0" y="40"></rect><text x="430.5" y="55">statements</text></g><path d="M483.0 51h15"></path><path d="M378.0 51a15 15 0 0 0 -15 15v12a15 15 0 0 0 15 15"></path><g class="terminal"> +<path d="M378.0 93h8.5"></path><path d="M474.5 93h8.5"></path><rect height="22" rx="10" ry="10" width="88.0" x="386.5" y="82"></rect><text x="430.5" y="97">Exit For</text></g><path d="M483.0 93a15 15 0 0 0 15 -15v-12a15 15 0 0 0 -15 -15"></path></g><path d="M498.0 51h10"></path><path d="M508.0 51h10"></path><g class="terminal"> +<path d="M518.0 51h0.0"></path><path d="M572.0 51h0.0"></path><rect height="22" rx="10" ry="10" width="54.0" x="518.0" y="40"></rect><text x="545.0" y="55">Next</text></g><path d="M572.0 51h10"></path><g> +<path d="M582.0 51h0.0"></path><path d="M696.0 51h0.0"></path><path d="M582.0 51a15 15 0 0 0 15 -15v-1a15 15 0 0 1 15 -15"></path><g> +<path d="M612.0 20h54.0"></path></g><path d="M666.0 20a15 15 0 0 1 15 15v1a15 15 0 0 0 15 15"></path><path d="M582.0 51h30"></path><g class="terminal"> +<path d="M612.0 51h0.0"></path><path d="M666.0 51h0.0"></path><rect height="22" rx="10" ry="10" width="54.0" x="612.0" y="40"></rect><text x="639.0" y="55">item</text></g><path d="M666.0 51h30"></path></g></g><path d="M696.0 51h10"></path><path d="M 706.0 51 h 20 m -10 -10 v 20 m 10 -20 v 20"></path></g></svg>
\ No newline at end of file diff --git a/source/media/helpimg/sbasic/For-Next_statement.svg b/source/media/helpimg/sbasic/For-Next_statement.svg new file mode 100644 index 0000000000..0f268f1015 --- /dev/null +++ b/source/media/helpimg/sbasic/For-Next_statement.svg @@ -0,0 +1,52 @@ +<svg class="railroad-diagram" height="124" viewBox="0 0 1115.0 124" width="1115.0" xmlns="http://www.w3.org/2000/svg"> +<g transform="translate(.5 .5)"> +<style>/* <![CDATA[ */ + svg.railroad-diagram { + background-color:transparent; + } + svg.railroad-diagram path { + stroke-width:1; + stroke:black; + fill:rgba(0,0,0,0); + } + svg.railroad-diagram text { + font:bold 14px monospace; + font-family: Verdana, sans-serif; + text-anchor:middle; + } + svg.railroad-diagram text.label{ + text-anchor:start; + } + svg.railroad-diagram text.comment{ + font:italic 12px monospace; + } + svg.railroad-diagram rect{ + stroke-width:1; + stroke:black; + fill:transparent; + } + +/* ]]> */ +</style><g> +<path d="M20 41v20m10 -20v20m-10 -10h20"></path></g><path d="M40 51h10"></path><g> +<path d="M50 51h0.0"></path><path d="M1065.0 51h0.0"></path><g class="terminal"> +<path d="M50.0 51h0.0"></path><path d="M95.5 51h0.0"></path><rect height="22" rx="10" ry="10" width="45.5" x="50.0" y="40"></rect><text x="72.75" y="55">For</text></g><path d="M95.5 51h10"></path><path d="M105.5 51h10"></path><g class="terminal"> +<path d="M115.5 51h0.0"></path><path d="M195.0 51h0.0"></path><rect height="22" rx="10" ry="10" width="79.5" x="115.5" y="40"></rect><text x="155.25" y="55">counter</text></g><path d="M195.0 51h10"></path><path d="M205.0 51h10"></path><g class="terminal"> +<path d="M215.0 51h0.0"></path><path d="M243.5 51h0.0"></path><rect height="22" rx="10" ry="10" width="28.5" x="215.0" y="40"></rect><text x="229.25" y="55">=</text></g><path d="M243.5 51h10"></path><path d="M253.5 51h10"></path><g class="terminal"> +<path d="M263.5 51h0.0"></path><path d="M326.0 51h0.0"></path><rect height="22" rx="10" ry="10" width="62.5" x="263.5" y="40"></rect><text x="294.75" y="55">start</text></g><path d="M326.0 51h10"></path><path d="M336.0 51h10"></path><g class="terminal"> +<path d="M346.0 51h0.0"></path><path d="M383.0 51h0.0"></path><rect height="22" rx="10" ry="10" width="37.0" x="346.0" y="40"></rect><text x="364.5" y="55">To</text></g><path d="M383.0 51h10"></path><path d="M393.0 51h10"></path><g class="terminal"> +<path d="M403.0 51h0.0"></path><path d="M448.5 51h0.0"></path><rect height="22" rx="10" ry="10" width="45.5" x="403.0" y="40"></rect><text x="425.75" y="55">end</text></g><path d="M448.5 51h10"></path><g> +<path d="M458.5 51h0.0"></path><path d="M696.5 51h0.0"></path><path d="M458.5 51a15 15 0 0 0 15 -15v-1a15 15 0 0 1 15 -15"></path><g> +<path d="M488.5 20h178.0"></path></g><path d="M666.5 20a15 15 0 0 1 15 15v1a15 15 0 0 0 15 15"></path><path d="M458.5 51h30"></path><g> +<path d="M488.5 51h0.0"></path><path d="M666.5 51h0.0"></path><g class="terminal"> +<path d="M488.5 51h0.0"></path><path d="M542.5 51h0.0"></path><rect height="22" rx="10" ry="10" width="54.0" x="488.5" y="40"></rect><text x="515.5" y="55">Step</text></g><path d="M542.5 51h10"></path><g> +<path d="M552.5 51h0.0"></path><path d="M666.5 51h0.0"></path><path d="M552.5 51h30"></path><g class="terminal"> +<path d="M582.5 51h12.75"></path><path d="M623.75 51h12.75"></path><rect height="22" rx="10" ry="10" width="28.5" x="595.25" y="40"></rect><text x="609.5" y="55">1</text></g><path d="M636.5 51h30"></path><path d="M552.5 51a15 15 0 0 1 15 15v12a15 15 0 0 0 15 15"></path><g class="terminal"> +<path d="M582.5 93h0.0"></path><path d="M636.5 93h0.0"></path><rect height="22" rx="10" ry="10" width="54.0" x="582.5" y="82"></rect><text x="609.5" y="97">step</text></g><path d="M636.5 93a15 15 0 0 0 15 -15v-12a15 15 0 0 1 15 -15"></path></g></g><path d="M666.5 51h30"></path></g><path d="M696.5 51h10"></path><g> +<path d="M706.5 51h0.0"></path><path d="M841.5 51h0.0"></path><path d="M706.5 51h15"></path><g class="non-terminal"> +<path d="M721.5 51h0.0"></path><path d="M826.5 51h0.0"></path><rect height="22" width="105.0" x="721.5" y="40"></rect><text x="774.0" y="55">statements</text></g><path d="M826.5 51h15"></path><path d="M721.5 51a15 15 0 0 0 -15 15v12a15 15 0 0 0 15 15"></path><g class="terminal"> +<path d="M721.5 93h8.5"></path><path d="M818.0 93h8.5"></path><rect height="22" rx="10" ry="10" width="88.0" x="730.0" y="82"></rect><text x="774.0" y="97">Exit For</text></g><path d="M826.5 93a15 15 0 0 0 15 -15v-12a15 15 0 0 0 -15 -15"></path></g><path d="M841.5 51h10"></path><path d="M851.5 51h10"></path><g class="terminal"> +<path d="M861.5 51h0.0"></path><path d="M915.5 51h0.0"></path><rect height="22" rx="10" ry="10" width="54.0" x="861.5" y="40"></rect><text x="888.5" y="55">Next</text></g><path d="M915.5 51h10"></path><g> +<path d="M925.5 51h0.0"></path><path d="M1065.0 51h0.0"></path><path d="M925.5 51a15 15 0 0 0 15 -15v-1a15 15 0 0 1 15 -15"></path><g> +<path d="M955.5 20h79.5"></path></g><path d="M1035.0 20a15 15 0 0 1 15 15v1a15 15 0 0 0 15 15"></path><path d="M925.5 51h30"></path><g class="terminal"> +<path d="M955.5 51h0.0"></path><path d="M1035.0 51h0.0"></path><rect height="22" rx="10" ry="10" width="79.5" x="955.5" y="40"></rect><text x="995.25" y="55">counter</text></g><path d="M1035.0 51h30"></path></g></g><path d="M1065.0 51h10"></path><path d="M 1075.0 51 h 20 m -10 -10 v 20 m 10 -20 v 20"></path></g></svg>
\ No newline at end of file diff --git a/source/media/helpimg/sbasic/On-Error_statement.svg b/source/media/helpimg/sbasic/On-Error_statement.svg new file mode 100644 index 0000000000..69fb8df63f --- /dev/null +++ b/source/media/helpimg/sbasic/On-Error_statement.svg @@ -0,0 +1,45 @@ +<svg class="railroad-diagram" height="146" viewBox="0 0 598.5 146" width="598.5" xmlns="http://www.w3.org/2000/svg"> +<g transform="translate(.5 .5)"> +<style>/* <![CDATA[ */ + svg.railroad-diagram { + background-color:transparent; + } + svg.railroad-diagram path { + stroke-width:1; + stroke:black; + fill:rgba(0,0,0,0); + } + svg.railroad-diagram text { + font:bold 14px monospace; + font-family: Verdana, sans-serif; + text-anchor:middle; + } + svg.railroad-diagram text.label{ + text-anchor:start; + } + svg.railroad-diagram text.comment{ + font:italic 12px monospace; + } + svg.railroad-diagram rect{ + stroke-width:1; + stroke:black; + fill:transparent; + } + +/* ]]> */ +</style><g> +<path d="M20 21v20m10 -20v20m-10 -10h20"></path></g><path d="M40 31h10"></path><g> +<path d="M50 31h0.0"></path><path d="M548.5 31h0.0"></path><g class="terminal"> +<path d="M50.0 31h0.0"></path><path d="M87.0 31h0.0"></path><rect height="22" rx="10" ry="10" width="37.0" x="50.0" y="20"></rect><text x="68.5" y="35">On</text></g><path d="M87.0 31h10"></path><g> +<path d="M97.0 31h0.0"></path><path d="M219.5 31h0.0"></path><path d="M97.0 31h30"></path><g> +<path d="M127.0 31h62.5"></path></g><path d="M189.5 31h30"></path><path d="M97.0 31a15 15 0 0 1 15 15v1a15 15 0 0 0 15 15"></path><g class="terminal"> +<path d="M127.0 62h0.0"></path><path d="M189.5 62h0.0"></path><rect height="22" rx="10" ry="10" width="62.5" x="127.0" y="51"></rect><text x="158.25" y="66">Local</text></g><path d="M189.5 62a15 15 0 0 0 15 -15v-1a15 15 0 0 1 15 -15"></path></g><path d="M219.5 31h10"></path><g class="terminal"> +<path d="M229.5 31h0.0"></path><path d="M292.0 31h0.0"></path><rect height="22" rx="10" ry="10" width="62.5" x="229.5" y="20"></rect><text x="260.75" y="35">Error</text></g><path d="M292.0 31h10"></path><g> +<path d="M302.0 31h0.0"></path><path d="M548.5 31h0.0"></path><path d="M302.0 31h30"></path><g> +<path d="M332.0 31h0.0"></path><path d="M518.5 31h0.0"></path><g class="terminal"> +<path d="M332.0 31h0.0"></path><path d="M386.0 31h0.0"></path><rect height="22" rx="10" ry="10" width="54.0" x="332.0" y="20"></rect><text x="359.0" y="35">GoTo</text></g><path d="M386.0 31h10"></path><g> +<path d="M396.0 31h0.0"></path><path d="M518.5 31h0.0"></path><path d="M396.0 31h30"></path><g class="terminal"> +<path d="M426.0 31h0.0"></path><path d="M488.5 31h0.0"></path><rect height="22" rx="10" ry="10" width="62.5" x="426.0" y="20"></rect><text x="457.25" y="35">label</text></g><path d="M488.5 31h30"></path><path d="M396.0 31a15 15 0 0 1 15 15v12a15 15 0 0 0 15 15"></path><g class="terminal"> +<path d="M426.0 73h17.0"></path><path d="M471.5 73h17.0"></path><rect height="22" rx="10" ry="10" width="28.5" x="443.0" y="62"></rect><text x="457.25" y="77">0</text></g><path d="M488.5 73a15 15 0 0 0 15 -15v-12a15 15 0 0 1 15 -15"></path></g></g><path d="M518.5 31h30"></path><path d="M302.0 31a15 15 0 0 1 15 15v54a15 15 0 0 0 15 15"></path><g> +<path d="M332.0 115h36.5"></path><path d="M482.0 115h36.5"></path><g class="terminal"> +<path d="M368.5 115h0.0"></path><path d="M482.0 115h0.0"></path><rect height="22" rx="10" ry="10" width="113.5" x="368.5" y="104"></rect><text x="425.25" y="119">Resume Next</text></g></g><path d="M518.5 115a15 15 0 0 0 15 -15v-54a15 15 0 0 1 15 -15"></path></g></g><path d="M548.5 31h10"></path><path d="M 558.5 31 h 20 m -10 -10 v 20 m 10 -20 v 20"></path></g></svg>
\ No newline at end of file diff --git a/source/text/sbasic/shared/03050500.xhp b/source/text/sbasic/shared/03050500.xhp index d86bad1299..80b3f1fba9 100644 --- a/source/text/sbasic/shared/03050500.xhp +++ b/source/text/sbasic/shared/03050500.xhp @@ -40,6 +40,9 @@ </section> <paragraph id="hd_id3151212" role="heading" level="2" xml-lang="en-US">Syntax:</paragraph> +<paragraph role="paragraph" id="par_id491585753339474"> + <image src="media/helpimg/sbasic/On-Error_statement.svg" id="img_id4156296484514"><alt xml-lang="en-US" id="alt_id15152796484514">On Error Statement diagram</alt></image> +</paragraph> <bascode> <paragraph id="par_id3145173" role="bascode" xml-lang="en-US">On {[Local] Error GoTo Labelname | GoTo 0 | Resume Next}</paragraph> </bascode> diff --git a/source/text/sbasic/shared/03090202.xhp b/source/text/sbasic/shared/03090202.xhp index 7e452db30b..7fc43cdf41 100644 --- a/source/text/sbasic/shared/03090202.xhp +++ b/source/text/sbasic/shared/03090202.xhp @@ -31,74 +31,93 @@ <section id="fornext"> <bookmark xml-lang="en-US" branch="index" id="bm_id3149205"> <bookmark_value>For statement</bookmark_value> - <bookmark_value>To statement</bookmark_value> - <bookmark_value>Step statement</bookmark_value> - <bookmark_value>Next statement</bookmark_value> + <bookmark_value>For Each statement</bookmark_value> + <bookmark_value>In keyword</bookmark_value> + <bookmark_value>Next keyword</bookmark_value> + <bookmark_value>Step keyword</bookmark_value> + <bookmark_value>To keyword</bookmark_value> + <bookmark_value>Step keyword</bookmark_value> </bookmark> -<paragraph id="hd_id3149205" role="heading" level="1" xml-lang="en-US"><link href="text/sbasic/shared/03090202.xhp" name="For...Next Statement">For...Next Statement</link></paragraph> -<paragraph id="par_id3143267" role="paragraph" xml-lang="en-US">Repeats the statements between the For...Next block a specified number of times.</paragraph> +<h1 id="hd_id3149205" xml-lang="en-US"><link href="text/sbasic/shared/03090202.xhp" name="For...Next Statement">For...Next Statement</link></h1> + <paragraph id="par_id3143267" role="paragraph" xml-lang="en-US">Repeats the statements between the <literal>For...Next</literal> block a specified number of times.</paragraph> </section> -<paragraph id="hd_id3156153" role="heading" level="2" xml-lang="en-US">Syntax:</paragraph> +<h2 id="hd_id3156153" xml-lang="en-US">Syntax:</h2> +<paragraph role="paragraph" id="par_id491585753339474"> + <image src="media/helpimg/sbasic/For-Next_statement.svg" id="img_id4156296484514"><alt xml-lang="en-US" id="alt_id15152796484514">For Statement diagram</alt></image> +</paragraph> <bascode> -<paragraph id="par_id3148473" role="bascode" xml-lang="en-US">For counter=start To end [Step step]</paragraph> -<paragraph id="par_id3156024" role="bascode" xml-lang="en-US">statement block</paragraph> -<paragraph id="par_id3146796" role="bascode" xml-lang="en-US">[Exit For]</paragraph> -<paragraph id="par_id3159414" role="bascode" xml-lang="en-US">statement block</paragraph> -<paragraph id="par_id3153897" role="bascode" xml-lang="en-US">Next [counter]</paragraph> +<paragraph id="par_id3148473" role="bascode" localize="false">For counter=start To end [Step step]</paragraph> +<paragraph id="par_id3156024" role="bascode" xml-lang="en-US"> statement-block</paragraph> +<paragraph id="par_id3146796" role="bascode" localize="false"> [Exit For]</paragraph> +<paragraph id="par_id3159414" role="bascode" xml-lang="en-US"> statement-block</paragraph> +<paragraph id="par_id3153897" role="bascode" localize="false">Next [counter]</paragraph> +</bascode> +<paragraph role="paragraph" id="par_id491585653339474"> + <image src="media/helpimg/sbasic/For-Each_statement.svg" id="img_id4156297484514"><alt xml-lang="en-US" id="alt_id15152797484514">For Each Statement diagram</alt></image> +</paragraph> +<bascode> + <paragraph role="bascode" id="bas_id331586521232310" localize="false">For Each item In list</paragraph> + <paragraph role="bascode" id="bas_id821586521234861" xml-lang="en-US"> statement-block</paragraph> + <paragraph role="bascode" id="bas_id991586521235339" localize="false">[Exit For]</paragraph> + <paragraph role="bascode" id="bas_id501586521235517" xml-lang="en-US"> statement-block</paragraph> + <paragraph role="bascode" id="bas_id941586521235718" localize="false">Next [item]</paragraph> </bascode> -<paragraph id="hd_id3150400" role="heading" level="2" xml-lang="en-US">Variables:</paragraph> -<paragraph id="par_id3150358" role="paragraph" xml-lang="en-US"> <emph>Counter:</emph> Loop counter initially assigned the value to the right of the equal sign (start). Only numeric variables are valid. The loop counter increases or decreases according to the variable Step until End is passed.</paragraph> -<paragraph id="par_id3152455" role="paragraph" xml-lang="en-US"> <emph>Start:</emph> Numeric variable that defines the initial value at the beginning of the loop.</paragraph> -<paragraph id="par_id3151043" role="paragraph" xml-lang="en-US"> <emph>End:</emph> Numeric variable that defines the final value at the end of the loop.</paragraph> -<paragraph id="par_id3156281" role="paragraph" xml-lang="en-US"> <emph>Step:</emph> Sets the value by which to increase or decrease the loop counter. If Step is not specified, the loop counter is incremented by 1. In this case, End must be greater than Start. If you want to decrease Counter, End must be less than Start, and Step must be assigned a negative value.</paragraph> +<h2 id="hd_id3150400" xml-lang="en-US">Variables:</h2> +<paragraph id="par_id3150358" role="paragraph" xml-lang="en-US"> <emph>counter:</emph> Loop <literal>counter</literal> initially assigned the value to the right of the equal sign (<literal>start</literal>). Only numeric variables are valid. The loop counter increases or decreases according to the variable <literal>step</literal> until <literal>end</literal> is passed.</paragraph> +<paragraph id="par_id3152455" role="paragraph" xml-lang="en-US"> <emph>start:</emph> Numeric variable that defines the initial value at the beginning of the loop.</paragraph> +<paragraph id="par_id3151043" role="paragraph" xml-lang="en-US"> <emph>end:</emph> Numeric variable that defines the final value at the end of the loop.</paragraph> +<paragraph id="par_id3156281" role="paragraph" xml-lang="en-US"> <emph>step:</emph> Sets the value by which to increase or decrease the loop counter. If <literal>step</literal> is not specified, the loop counter is incremented by 1. In this case, <literal>end</literal> must be greater than <literal>start</literal>. If you want to decrease <literal>counter</literal>, <literal>end</literal> must be less than <literal>start</literal>, and <literal>step</literal> must be assigned a negative value.</paragraph> <paragraph id="par_id3154684" role="paragraph" xml-lang="en-US">The <emph>For...Next</emph> loop repeats all of the statements in the loop for the number of times that is specified by the parameters.</paragraph> -<paragraph id="par_id3147287" role="paragraph" xml-lang="en-US">As the counter variable is decreased, $[officename] Basic checks if the end value has been reached. As soon as the counter passes the end value, the loop automatically ends.</paragraph> +<paragraph id="par_id3147287" role="paragraph" xml-lang="en-US">As the <literal>counter</literal> variable is decreased, %PRODUCTNAME Basic checks if the <literal>end</literal> value has been reached. As soon as the <literal>counter</literal> passes the <literal>end</literal> value, the loop automatically terminates.</paragraph> <paragraph id="par_id3159154" role="paragraph" xml-lang="en-US">It is possible to nest <emph>For...Next</emph> statements. If you do not specify a variable following the <emph>Next</emph> statement, <emph>Next</emph> automatically refers to the most recent <emph>For</emph> statement.</paragraph> <paragraph id="par_id3155306" role="paragraph" xml-lang="en-US">If you specify an increment of 0, the statements between <emph>For</emph> and <emph>Next</emph> are repeated continuously.</paragraph> -<paragraph id="par_id3155854" role="paragraph" xml-lang="en-US">When counting down the counter variable, $[officename] Basic checks for overflow or underflow. The loop ends when Counter exceeds End (positive Step value) or is less than End (negative Step value).</paragraph> +<paragraph id="par_id3155854" role="paragraph" xml-lang="en-US">When counting down the counter variable, %PRODUCTNAME Basic checks for overflow or underflow. The loop ends when <literal>counter</literal> exceeds <literal>end</literal> (positive Step value) or is less than <literal>end</literal> (negative Step value).</paragraph> <paragraph id="par_id3145273" role="paragraph" xml-lang="en-US">Use the <emph>Exit For</emph> statement to exit the loop unconditionally. This statement must be within a <emph>For...Next</emph> loop. Use the <emph>If...Then</emph> statement to test the exit condition as follows:</paragraph> -<paragraph id="par_id3153190" role="paragraph" xml-lang="en-US">For...</paragraph> -<paragraph id="par_id3149482" role="paragraph" xml-lang="en-US">statements</paragraph> -<paragraph id="par_id3147124" role="paragraph" xml-lang="en-US">If condition = True Then Exit For</paragraph> -<paragraph id="par_id3153159" role="paragraph" xml-lang="en-US">statements</paragraph> -<paragraph id="par_id3154096" role="paragraph" xml-lang="en-US">Next</paragraph> -<paragraph id="par_id3156286" role="paragraph" xml-lang="en-US">Note: In nested <emph>For...Next</emph> loops, if you exit a loop unconditionally with <emph>Exit For</emph>, only one loop is exited.</paragraph> +<bascode> + <paragraph role="bascode" id="bas_id631586522581351" localize="false">For...</paragraph> + <paragraph role="bascode" id="bas_id621586522583437" xml-lang="en-US"> statement-block</paragraph> + <paragraph role="bascode" id="bas_id571586522583814" localize="false"> If condition = True Then Exit For</paragraph> + <paragraph role="bascode" id="bas_id711586522584013" xml-lang="en-US"> statement-block</paragraph> + <paragraph role="bascode" id="bas_id831586522584527" localize="false">Next</paragraph> +</bascode> -<paragraph id="hd_id3148457" role="heading" level="2" xml-lang="en-US">Example</paragraph> -<paragraph id="par_id3151074" role="paragraph" xml-lang="en-US">The following example uses two nested loops to sort a string array with 10 elements ( sEntry() ), that are first filled with various contents:</paragraph> +<note id="par_id3156286" xml-lang="en-US">In nested <emph>For...Next</emph> loops, if you exit a loop unconditionally with <emph>Exit For</emph>, only one loop is exited.</note> + +<h2 id="hd_id3148457" xml-lang="en-US">Examples</h2> +<paragraph id="par_id3151074" role="paragraph" xml-lang="en-US">The following example uses two nested loops to sort a string array with 10 elements ( sEntry() ), that is filled with various contents:</paragraph> +<bascode> +<paragraph id="par_idm1341539088" role="bascode" localize="false">Sub ExampleSort</paragraph> +<paragraph id="par_idm1340517312" role="bascode" localize="false">Dim sEntry(9) As String</paragraph> +<paragraph id="par_idm1340516080" role="bascode" localize="false">Dim iCount As Integer, iCount2 As Integer</paragraph> +<paragraph id="par_idm1340513616" role="bascode" localize="false">Dim sTemp As String</paragraph> +<paragraph id="par_id31557349267" role="bascode" localize="false"> sEntry = Array("Jerry","Patty","Kurt","Thomas","Michael",_</paragraph> +<paragraph id="par_id49231539711" role="bascode" localize="false"> "David","Cathy","Susie","Edward","Christine")</paragraph> +<paragraph id="par_idm1340495152" role="bascode" localize="false"> For iCount = 0 To 9</paragraph> +<paragraph id="par_idm1340493920" role="bascode" localize="false"> For iCount2 = iCount + 1 To 9</paragraph> +<paragraph id="par_idm1340492672" role="bascode" localize="false"> If sEntry(iCount) > sEntry(iCount2) Then</paragraph> +<paragraph id="par_idm1340491296" role="bascode" localize="false"> sTemp = sEntry(iCount)</paragraph> +<paragraph id="par_idm1340490096" role="bascode" localize="false"> sEntry(iCount) = sEntry(iCount2)</paragraph> +<paragraph id="par_idm1340488832" role="bascode" localize="false"> sEntry(iCount2) = sTemp</paragraph> +<paragraph id="par_idm1340487584" role="bascode" localize="false"> End If</paragraph> +<paragraph id="par_idm1340486352" role="bascode" localize="false"> Next iCount2</paragraph> +<paragraph id="par_idm1340485120" role="bascode" localize="false"> Next iCount</paragraph> +<paragraph id="par_idm1340483888" role="bascode" localize="false"> For iCount = 0 To 9</paragraph> +<paragraph id="par_idm1340482656" role="bascode" localize="false"> Print sEntry(iCount)</paragraph> +<paragraph id="par_idm1340481408" role="bascode" localize="false"> Next iCount</paragraph> +<paragraph id="par_idm1340480176" role="bascode" localize="false">End Sub</paragraph> +</bascode> +<paragraph role="paragraph" id="par_id561586524231943">This explores the content of an array to display each item it contains.</paragraph> <bascode> -<paragraph id="par_idm1341539088" role="bascode" localize="false" xml-lang="en-US">Sub ExampleSort</paragraph> -<paragraph id="par_idm1340517312" role="bascode" localize="false" xml-lang="en-US">Dim sEntry(9) As String</paragraph> -<paragraph id="par_idm1340516080" role="bascode" localize="false" xml-lang="en-US">Dim iCount As Integer</paragraph> -<paragraph id="par_idm1340514848" role="bascode" localize="false" xml-lang="en-US">Dim iCount2 As Integer</paragraph> -<paragraph id="par_idm1340513616" role="bascode" localize="false" xml-lang="en-US">Dim sTemp As String</paragraph> -<paragraph id="par_id3155767" role="bascode" xml-lang="en-US"> sEntry(0) = "Jerry"</paragraph> -<paragraph id="par_id3153711" role="bascode" xml-lang="en-US"> sEntry(1) = "Patty"</paragraph> -<paragraph id="par_id3148993" role="bascode" xml-lang="en-US"> sEntry(2) = "Kurt"</paragraph> -<paragraph id="par_id3156382" role="bascode" xml-lang="en-US"> sEntry(3) = "Thomas"</paragraph> -<paragraph id="par_id3155174" role="bascode" xml-lang="en-US"> sEntry(4) = "Michael"</paragraph> -<paragraph id="par_id3166448" role="bascode" xml-lang="en-US"> sEntry(5) = "David"</paragraph> -<paragraph id="par_id3149255" role="bascode" xml-lang="en-US"> sEntry(6) = "Cathy"</paragraph> -<paragraph id="par_id3149565" role="bascode" xml-lang="en-US"> sEntry(7) = "Susie"</paragraph> -<paragraph id="par_id3145148" role="bascode" xml-lang="en-US"> sEntry(8) = "Edward"</paragraph> -<paragraph id="par_id3145229" role="bascode" xml-lang="en-US"> sEntry(9) = "Christine"</paragraph> -<paragraph id="par_idm1340495152" role="bascode" localize="false" xml-lang="en-US"> For iCount = 0 To 9</paragraph> -<paragraph id="par_idm1340493920" role="bascode" localize="false" xml-lang="en-US"> For iCount2 = iCount + 1 To 9</paragraph> -<paragraph id="par_idm1340492672" role="bascode" localize="false" xml-lang="en-US"> If sEntry(iCount) > sEntry(iCount2) Then</paragraph> -<paragraph id="par_idm1340491296" role="bascode" localize="false" xml-lang="en-US"> sTemp = sEntry(iCount)</paragraph> -<paragraph id="par_idm1340490096" role="bascode" localize="false" xml-lang="en-US"> sEntry(iCount) = sEntry(iCount2)</paragraph> -<paragraph id="par_idm1340488832" role="bascode" localize="false" xml-lang="en-US"> sEntry(iCount2) = sTemp</paragraph> -<paragraph id="par_idm1340487584" role="bascode" localize="false" xml-lang="en-US"> End If</paragraph> -<paragraph id="par_idm1340486352" role="bascode" localize="false" xml-lang="en-US"> Next iCount2</paragraph> -<paragraph id="par_idm1340485120" role="bascode" localize="false" xml-lang="en-US"> Next iCount</paragraph> -<paragraph id="par_idm1340483888" role="bascode" localize="false" xml-lang="en-US"> For iCount = 0 To 9</paragraph> -<paragraph id="par_idm1340482656" role="bascode" localize="false" xml-lang="en-US"> Print sEntry(iCount)</paragraph> -<paragraph id="par_idm1340481408" role="bascode" localize="false" xml-lang="en-US"> Next iCount</paragraph> -<paragraph id="par_idm1340480176" role="bascode" localize="false" xml-lang="en-US">End Sub</paragraph> + <paragraph role="bascode" id="bas_id511586523090639">Sub list_iteration</paragraph> + <paragraph role="bascode" id="bas_id391586523091799"> cutlery = Array("fork", "knife", "spoon")</paragraph> + <paragraph role="bascode" id="bas_id811586523092655"> For Each item in cutlery</paragraph> + <paragraph role="bascode" id="bas_id271586523092911"> Print item</paragraph> + <paragraph role="bascode" id="bas_id941586523093415"> Next ' item</paragraph> + <paragraph role="bascode" id="bas_id301586523093607">End Sub</paragraph> </bascode> </body> |