summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlain Romedenne <alain.romedenne@libreoffice.org>2022-04-04 16:58:11 +0100
committerAlain Romedenne <alain.romedenne@libreoffice.org>2022-05-09 17:43:19 +0200
commit084d84f09882ec35007ad4566247932a30899799 (patch)
tree08ffcbf6c7917d3e65967513fb12e678f4c25ade
parent886426b32dfefc962fc700dbf3adfeca7ca3c15e (diff)
tdf#141474 tdf#148466 Choose function accepts keyword arguments
Change-Id: I82407ecc20b66c385f17509aa703222d2d2d10e6 Reviewed-on: https://gerrit.libreoffice.org/c/help/+/132390 Tested-by: Jenkins Reviewed-by: Alain Romedenne <alain.romedenne@libreoffice.org>
-rw-r--r--source/text/sbasic/shared/03090102.xhp4
-rw-r--r--source/text/sbasic/shared/03090402.xhp48
-rw-r--r--source/text/sbasic/shared/03090410.xhp18
3 files changed, 44 insertions, 26 deletions
diff --git a/source/text/sbasic/shared/03090102.xhp b/source/text/sbasic/shared/03090102.xhp
index 55791f203a..571abc33d2 100644
--- a/source/text/sbasic/shared/03090102.xhp
+++ b/source/text/sbasic/shared/03090102.xhp
@@ -35,7 +35,7 @@
</bookmark>
-<paragraph id="hd_id3149416" role="heading" level="1" xml-lang="en-US"><link href="text/sbasic/shared/03090102.xhp" name="Select...Case Statement">Select...Case Statement</link></paragraph>
+<h1 id="hd_id3149416" xml-lang="en-US"><variable id="Select_h1"><link href="text/sbasic/shared/03090102.xhp" name="Select...Case Statement">Select...Case Statement</link></variable></h1>
<paragraph id="par_id3153896" role="paragraph" xml-lang="en-US">Defines one or more statement blocks depending on the value of an expression.</paragraph>
</section>
@@ -75,6 +75,8 @@
</bascode>
<section id="relatedtopics">
+ <embed href="text/sbasic/shared/03090402.xhp#Choose_h1"/>
+ <embed href="text/sbasic/shared/03090410.xhp#Switch_h1"/>
<paragraph role="paragraph" id="par_id161588865796615"><link href="text/sbasic/shared/03090101.xhp" name="If...Then...Else statement">If</link> statement</paragraph>
<paragraph role="paragraph" id="par_id281588865818334"><link href="text/sbasic/shared/03090103.xhp" name="Iif function">Iif</link> or <link href="text/sbasic/shared/03090410.xhp" name="Switch function">Switch</link> functions</paragraph>
</section>
diff --git a/source/text/sbasic/shared/03090402.xhp b/source/text/sbasic/shared/03090402.xhp
index 3f70ca35e7..12b5d7f62c 100644
--- a/source/text/sbasic/shared/03090402.xhp
+++ b/source/text/sbasic/shared/03090402.xhp
@@ -34,36 +34,48 @@
</bookmark>
-<paragraph id="hd_id3143271" role="heading" level="1" xml-lang="en-US"><link href="text/sbasic/shared/03090402.xhp" name="Choose Function">Choose Function</link></paragraph>
+<h1 id="hd_id3143271" xml-lang="en-US"><variable id="Choose_h1"><link href="text/sbasic/shared/03090402.xhp" name="Choose Function">Choose Function</link></variable></h1>
<paragraph id="par_id3149234" role="paragraph" xml-lang="en-US">Returns a selected value from a list of arguments.</paragraph>
</section>
-<paragraph id="hd_id3148943" role="heading" level="2" xml-lang="en-US">Syntax:</paragraph>
+<embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
<bascode>
-<paragraph id="par_id3147560" role="bascode" xml-lang="en-US">Choose (Index, Selection1[, Selection2, ... [,Selection_n]])</paragraph>
+ <paragraph id="par_id3147560" role="bascode" localize="false">Choose (Index As Integer, Expression1[, Expression2, ... [, Expression_n]]) As Variant</paragraph>
</bascode>
+<embed href="text/sbasic/shared/00000003.xhp#functvalue"/>
+<paragraph role="paragraph" id="par_id131649410695924">Variant. A value infered from the <literal>Index</literal> parameter.</paragraph>
-<paragraph id="hd_id3154346" role="heading" level="2" xml-lang="en-US">Parameters:</paragraph>
-<paragraph id="par_id3148664" role="paragraph" xml-lang="en-US"> <emph>Index:</emph> Integer value starting at 1 that specifies which of the possible choices to return.</paragraph>
-<paragraph id="par_id3150791" role="paragraph" xml-lang="en-US"> <emph>Selection1:</emph> Any expression that contains one of the possible choices.</paragraph>
+<embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+<paragraph id="par_id3148664" role="paragraph" xml-lang="en-US"> <emph>Index</emph>: Any numeric expression rounded to a whole number. <literal>Index</literal> accepts integer values starting at 1 that specify which of the possible choices to return.</paragraph>
+<paragraph id="par_id3150791" role="paragraph" xml-lang="en-US"> <emph>Expression1, Expression2, …, Expression_n</emph>: Expressions representing each of the possible choices.</paragraph>
<paragraph id="par_id3151043" role="paragraph" xml-lang="en-US">The <emph>Choose</emph> function returns a value from the list of expressions based on the index value. If <emph>Index = 1</emph>, the function returns the first expression in the list, if <emph>Index = 2</emph>, it returns the second expression, and so on.</paragraph>
-<paragraph id="par_id3153192" role="paragraph" xml-lang="en-US">If the index value is less than 1 or greater than the number of expressions listed, the function returns a Null value.</paragraph>
-<paragraph id="par_id3156281" role="paragraph" xml-lang="en-US">The following example uses the <emph>Choose</emph> function to select a string from several strings that form a menu:</paragraph>
+<paragraph id="par_id3153192" role="paragraph" xml-lang="en-US">If the index value is less than 1 or greater than the number of expressions listed, the function returns a <literal>Null</literal> value.</paragraph>
+<paragraph role="paragraph" id="par_id911649410528836">Error #5 occurs when parameters are omitted. Error #13 occurs if <literal>Index</literal> equals <literal>Null</literal>.
+<comment> If expressions are omitted - e.g. Choose(5) - or Index=Null, Basic runtime raises error #13. If the chosen expression is not defined -e.g. Choose(2,"a",,45) - "Error 448" is returned !!.</comment></paragraph>
+
<embed href="text/sbasic/shared/00000003.xhp#errorcode"/>
<embed href="text/sbasic/shared/00000003.xhp#err5"/>
+<embed href="text/sbasic/shared/00000003.xhp#err13"/>
+
+<embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+<paragraph id="par_id3156281" role="paragraph" xml-lang="en-US">The following example uses the or <literal>Choose</literal> function to select a string from several strings that form a menu:</paragraph>
-<paragraph id="hd_id3150439" role="heading" level="2" xml-lang="en-US">Example:</paragraph>
<bascode>
-<paragraph id="par_idm871799424" role="bascode" localize="false" xml-lang="en-US">Sub ExampleChoose</paragraph>
-<paragraph id="par_idm871798192" role="bascode" localize="false" xml-lang="en-US">Dim sReturn As String</paragraph>
-<paragraph id="par_idm871796960" role="bascode" localize="false" xml-lang="en-US"> sReturn = ChooseMenu(2)</paragraph>
-<paragraph id="par_idm871795712" role="bascode" localize="false" xml-lang="en-US"> Print sReturn</paragraph>
-<paragraph id="par_idm871794480" role="bascode" localize="false" xml-lang="en-US">End Sub</paragraph>
-<paragraph id="par_idm871793248" role="bascode" localize="false" xml-lang="en-US"> </paragraph>
-<paragraph id="par_idm871792000" role="bascode" localize="false" xml-lang="en-US">Function ChooseMenu(Index As Integer)</paragraph>
+<paragraph id="par_idm871799424" role="bascode" localize="false">Sub ExampleChoose</paragraph>
+<paragraph id="par_idm871795712" role="bascode" xml-lang="en-US"> Print ChooseMenu(2) ' "Save Format"</paragraph>
+<paragraph role="bascode" id="bas_id101649409956174" localize="false"> MsgBox Choose(index := -5, 9, "Basic", PI) ' Null</paragraph>
+<paragraph role="bascode" id="bas_id291649409956630" localize="false"> MsgBox Choose(index := 3.14, 9, "Basic", PI) ' PI</paragraph>
+<paragraph id="par_idm871794480" role="bascode" localize="false">End Sub</paragraph>
+<paragraph id="par_idm871793248" role="bascode" localize="false"> </paragraph>
+<paragraph id="par_idm871792000" role="bascode" localize="false">Function ChooseMenu(Index As Integer)</paragraph>
<paragraph id="par_id3156443" role="bascode" xml-lang="en-US"> ChooseMenu = Choose(Index, "Quick Format", "Save Format", "System Format")</paragraph>
-<paragraph id="par_idm871788976" role="bascode" localize="false" xml-lang="en-US">End Function</paragraph>
+<paragraph id="par_idm871788976" role="bascode" localize="false">End Function</paragraph>
</bascode>
-</body>
+<section id="relatedtopics">
+ <embed href="text/sbasic/shared/03090102.xhp#Select_h1"/>
+ <embed href="text/sbasic/shared/03090410.xhp#Switch_h1"/>
+</section>
+
+</body>
</helpdocument> \ No newline at end of file
diff --git a/source/text/sbasic/shared/03090410.xhp b/source/text/sbasic/shared/03090410.xhp
index cec0930676..acade098ee 100644
--- a/source/text/sbasic/shared/03090410.xhp
+++ b/source/text/sbasic/shared/03090410.xhp
@@ -33,17 +33,16 @@
<bookmark_value>Switch function</bookmark_value>
</bookmark>
-
-<paragraph id="hd_id3148554" role="heading" level="1" xml-lang="en-US"><link href="text/sbasic/shared/03090410.xhp" name="Switch Function">Switch Function</link></paragraph>
+<h1 id="hd_id3148554" xml-lang="en-US"><variable id="Switch_h1"><link href="text/sbasic/shared/03090410.xhp" name="Switch Function">Switch Function</link></variable></h1>
<paragraph id="par_id3148522" role="paragraph" xml-lang="en-US">Evaluates a list of arguments, consisting of an expression followed by a value. The Switch function returns a value that is associated with the expression that is passed by this function.</paragraph>
</section>
-<paragraph id="hd_id3154863" role="heading" level="2" xml-lang="en-US">Syntax:</paragraph>
+<embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
<bascode>
-<paragraph id="par_id3155934" role="bascode" xml-lang="en-US">Switch (Expression1, Value1[, Expression2, Value2[..., Expression_n, Value_n]])</paragraph>
+<paragraph id="par_id3155934" role="bascode" xml-lang="en-US">Switch (Expression1, Value1[, Expression2, Value2[..., Expression_n, Value_n]]) As Variant</paragraph>
</bascode>
-<paragraph id="hd_id3149119" role="heading" level="2" xml-lang="en-US">Parameters:</paragraph>
+<embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
<paragraph id="par_id3153894" role="paragraph" xml-lang="en-US">The <emph>Switch</emph> function evaluates the expressions from left to right, and then returns the value that is assigned to the function expression. If expression and value are not given as a pair, a runtime error occurs.</paragraph>
<paragraph id="par_id3153990" role="paragraph" xml-lang="en-US"> <emph>Expression:</emph> The expression that you want to evaluate.</paragraph>
<paragraph id="par_id3153394" role="paragraph" xml-lang="en-US"> <emph>Value:</emph> The value that you want to return if the expression is True.</paragraph>
@@ -51,7 +50,7 @@
<embed href="text/sbasic/shared/00000003.xhp#errorcode"/>
<embed href="text/sbasic/shared/00000003.xhp#err5"/>
-<paragraph id="hd_id3159157" role="heading" level="2" xml-lang="en-US">Example:</paragraph>
+<embed href="text/sbasic/shared/00000003.xhp#functexample"/>
<bascode>
<paragraph id="par_idm1341052032" role="bascode" localize="false" xml-lang="en-US">Sub ExampleSwitch</paragraph>
<paragraph id="par_idm1341050800" role="bascode" localize="false" xml-lang="en-US">Dim sGender As String</paragraph>
@@ -63,6 +62,11 @@
<paragraph id="par_id3153361" role="bascode" xml-lang="en-US"> GetGenderIndex = Switch(sName = "Jane", "female", sName = "John", "male")</paragraph>
<paragraph id="par_idm1341041088" role="bascode" localize="false" xml-lang="en-US">End Function</paragraph>
</bascode>
-</body>
+<section id="relatedtopics">
+ <embed href="text/sbasic/shared/03090402.xhp#Choose_h1"/>
+ <embed href="text/sbasic/shared/03090102.xhp#Select_h1"/>
+</section>
+
+</body>
</helpdocument> \ No newline at end of file