summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Package_html_media.mk1
-rw-r--r--source/media/helpimg/sbasic/Const_statement.svg44
-rw-r--r--source/text/sbasic/shared/03100700.xhp50
3 files changed, 77 insertions, 18 deletions
diff --git a/Package_html_media.mk b/Package_html_media.mk
index bfe868dbf9..2a7a8e767b 100644
--- a/Package_html_media.mk
+++ b/Package_html_media.mk
@@ -112,6 +112,7 @@ $(eval $(call gb_Package_add_files_with_dir,helpcontent2_html_media,$(LIBO_SHARE
helpimg/sbasic/char_fragment.svg \
helpimg/sbasic/typename_fragment.svg \
helpimg/sbasic/Call_statement.svg \
+ helpimg/sbasic/Const_statement.svg \
helpimg/sbasic/Dim_statement.svg \
helpimg/sbasic/DimArray_function.svg \
helpimg/sbasic/Do_statement.svg \
diff --git a/source/media/helpimg/sbasic/Const_statement.svg b/source/media/helpimg/sbasic/Const_statement.svg
new file mode 100644
index 0000000000..0cbc42b725
--- /dev/null
+++ b/source/media/helpimg/sbasic/Const_statement.svg
@@ -0,0 +1,44 @@
+<svg class="railroad-diagram" height="166" viewBox="0 0 639.5 166" width="639.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 83v20m10 -20v20m-10 -10h20"></path></g><g>
+<path d="M40 93h0.0"></path><path d="M239.5 93h0.0"></path><path d="M40.0 93a15 15 0 0 0 15 -15v-43a15 15 0 0 1 15 -15"></path><g>
+<path d="M70.0 20h139.5"></path></g><path d="M209.5 20a15 15 0 0 1 15 15v43a15 15 0 0 0 15 15"></path><path d="M40.0 93h30"></path><g>
+<path d="M70.0 93h0.0"></path><path d="M209.5 93h0.0"></path><path d="M70.0 93a15 15 0 0 0 15 -15v-12a15 15 0 0 1 15 -15"></path><g class="terminal">
+<path d="M100.0 51h4.25"></path><path d="M175.25 51h4.25"></path><rect height="22" rx="10" ry="10" width="71.0" x="104.25" y="40"></rect><text x="139.75" y="55">Global</text></g><path d="M179.5 51a15 15 0 0 1 15 15v12a15 15 0 0 0 15 15"></path><path d="M70.0 93h30"></path><g class="terminal">
+<path d="M100.0 93h0.0"></path><path d="M179.5 93h0.0"></path><rect height="22" rx="10" ry="10" width="79.5" x="100.0" y="82"></rect><text x="139.75" y="97">Private</text></g><path d="M179.5 93h30"></path><path d="M70.0 93a15 15 0 0 1 15 15v12a15 15 0 0 0 15 15"></path><g class="terminal">
+<path d="M100.0 135h4.25"></path><path d="M175.25 135h4.25"></path><rect height="22" rx="10" ry="10" width="71.0" x="104.25" y="124"></rect><text x="139.75" y="139">Public</text></g><path d="M179.5 135a15 15 0 0 0 15 -15v-12a15 15 0 0 1 15 -15"></path></g><path d="M209.5 93h30"></path></g><path d="M239.5 93h10"></path><g class="terminal">
+<path d="M249.5 93h0.0"></path><path d="M312.0 93h0.0"></path><rect height="22" rx="10" ry="10" width="62.5" x="249.5" y="82"></rect><text x="280.75" y="97">Const</text></g><path d="M312.0 93h10"></path><path d="M322.0 93h10"></path><g>
+<path d="M332.0 93h0.0"></path><path d="M589.5 93h0.0"></path><path d="M332.0 93h15"></path><g>
+<path d="M347.0 93h0.0"></path><path d="M574.5 93h0.0"></path><g class="terminal">
+<path d="M347.0 93h0.0"></path><path d="M401.0 93h0.0"></path><rect height="22" rx="10" ry="10" width="54.0" x="347.0" y="82"></rect><text x="374.0" y="97">name</text></g><path d="M401.0 93h10"></path><path d="M411.0 93h10"></path><g class="terminal">
+<path d="M421.0 93h0.0"></path><path d="M449.5 93h0.0"></path><rect height="22" rx="10" ry="10" width="28.5" x="421.0" y="82"></rect><text x="435.25" y="97">=</text></g><path d="M449.5 93h10"></path><path d="M459.5 93h10"></path><g class="terminal">
+<path d="M469.5 93h0.0"></path><path d="M574.5 93h0.0"></path><rect height="22" rx="10" ry="10" width="105.0" x="469.5" y="82"></rect><text x="522.0" y="97">expression</text></g></g><path d="M574.5 93h15"></path><path d="M347.0 93a15 15 0 0 0 -15 15v12a15 15 0 0 0 15 15"></path><g class="terminal">
+<path d="M347.0 135h99.5"></path><path d="M475.0 135h99.5"></path><rect height="22" rx="10" ry="10" width="28.5" x="446.5" y="124"></rect><text x="460.75" y="139">,</text></g><path d="M574.5 135a15 15 0 0 0 15 -15v-12a15 15 0 0 0 -15 -15"></path></g><path d="M589.5 93h10"></path><path d="M 599.5 93 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/03100700.xhp b/source/text/sbasic/shared/03100700.xhp
index f1c12c4809..14d00c83b1 100644
--- a/source/text/sbasic/shared/03100700.xhp
+++ b/source/text/sbasic/shared/03100700.xhp
@@ -33,29 +33,43 @@
</bookmark>
<paragraph id="hd_id3146958" role="heading" level="1" xml-lang="en-US"><link href="text/sbasic/shared/03100700.xhp" name="Const Statement">Const Statement</link></paragraph>
-<paragraph id="par_id3154143" role="paragraph" xml-lang="en-US">Defines a string as a constant.</paragraph>
+<paragraph id="par_id3154143" role="paragraph" xml-lang="en-US">Defines one or more identifiers as constants.</paragraph>
</section>
+<paragraph id="par_id3147264" role="paragraph" xml-lang="en-US">A constant is a variable that helps to improve the readability of a program. Constants are not defined as a specific type of variable, but rather are used as placeholders in the code. You can only define a constant once and it cannot be modified.</paragraph>
-<paragraph id="hd_id3150670" role="heading" level="2" xml-lang="en-US">Syntax:</paragraph>
+<embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+<paragraph role="image" id="par_id831588865616326">
+ <image src="media/helpimg/sbasic/Const_statement.svg" id="img_id651588865616326"><alt id="alt_id281588865616326">Const syntax</alt></image>
+</paragraph>
<bascode>
-<paragraph id="par_id3150984" role="bascode" xml-lang="en-US">Const Text = Expression</paragraph>
+<paragraph id="par_id3150984" role="bascode" xml-lang="en-US">[Global|Private|Public] Const name = expression[, ...]</paragraph>
</bascode>
-<paragraph id="hd_id3147530" role="heading" level="2" xml-lang="en-US">Parameters:</paragraph>
-<paragraph id="par_id3153897" role="paragraph" xml-lang="en-US"> <emph>Text:</emph> Any constant name that follows the standard variable naming conventions.</paragraph>
-<paragraph id="par_id3147264" role="paragraph" xml-lang="en-US">A constant is a variable that helps to improve the readability of a program. Constants are not defined as a specific type of variable, but rather are used as placeholders in the code. You can only define a constant once and it cannot be modified. Use the following statement to define a constant:</paragraph>
-<paragraph id="par_id3150542" role="paragraph" xml-lang="en-US">CONST ConstName=Expression</paragraph>
-<paragraph id="par_id3150400" role="paragraph" xml-lang="en-US">The type of expression is irrelevant. If a program is started, $[officename] Basic converts the program code internally so that each time a constant is used, the defined expression replaces it.</paragraph>
-
-<paragraph id="hd_id3154366" role="heading" level="2" xml-lang="en-US">Example:</paragraph>
+<embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+ <paragraph id="par_id3153897" role="paragraph"> <emph>name:</emph> Any identifier that follows the standard variable naming conventions.</paragraph>
+<paragraph role="paragraph" id="par_id791593689338208"><emph>expression:</emph> Any literal expression. </paragraph>
+<paragraph id="par_id3150400" role="paragraph" xml-lang="en-US">The data type must be omitted. When a library gets loaded in memory, %PRODUCTNAME Basic converts the program code internally so that each time a constant is used, the defined expression replaces it.</paragraph>
+<h3 id="hd_id51593690561479">Scope</h3>
+<paragraph role="paragraph" id="par_id431593690612961">By default constants are defined as private in modules and routines. Constants can be made public or global in order to be used from all modules, from all Basic libraries.</paragraph>
+<paragraph role="paragraph" id="par_id241593693307830"><literal>Global</literal>, <literal>Private</literal> and <literal>Public</literal> specifiers can only be used for module constants.</paragraph>
+<embed href="text/sbasic/shared/00000003.xhp#functexample"/>
<bascode>
-<paragraph id="par_idm1341161984" role="bascode" localize="false" xml-lang="en-US">Sub ExampleConst</paragraph>
-<paragraph id="par_idm1341160752" role="bascode" localize="false" xml-lang="en-US"> Const iVar = 1964</paragraph>
-<paragraph id="par_idm1341159520" role="bascode" localize="false" xml-lang="en-US"> MsgBox iVar</paragraph>
-<paragraph id="par_id3153969" role="bascode" xml-lang="en-US"> Const sVar = "Program", dVar As Double = 1.00</paragraph>
-<paragraph id="par_idm1341156544" role="bascode" localize="false" xml-lang="en-US"> MsgBox sVar &amp; " " &amp; dVar</paragraph>
-<paragraph id="par_idm1341155296" role="bascode" localize="false" xml-lang="en-US">End Sub</paragraph>
+ <paragraph role="bascode" id="bas_id911593692598060" xml-lang="en-US">Const EARTH = "♁" &apos; module scope</paragraph>
+ <paragraph role="bascode" id="bas_id441593692601125" xml-lang="en-US">Private Const MOON = "☾" &apos; module scope</paragraph>
+ <paragraph role="bascode" id="bas_id161593692601597" xml-lang="en-US">Public Const VENUS="♀", MARS="♂" &apos; general scope</paragraph>
+ <paragraph role="bascode" id="bas_id581593692602046" xml-lang="en-US">Global Const SUN = "☉", STAR = "☆" &apos; general scope</paragraph>
+ <paragraph role="bascode" id="bas_id711593692602477" localize="false"></paragraph>
+ <paragraph id="par_idm1341161984" role="bascode" localize="false">Sub ExampleConst</paragraph>
+ <paragraph id="par_idm1341160752" role="bascode" xml-lang="en-US"> Const SUN = 3 * 1.456 / 56 &apos; SUN is local</paragraph>
+ <paragraph id="par_idm1341159520" role="bascode" xml-lang="en-US"> MsgBox SUN,, MOON &apos; SUN global constant is unchanged</paragraph>
+ <paragraph id="par_id3153969" role="bascode" localize="false"> Const Pgm = "Program", Var = 1.00</paragraph>
+ <paragraph id="par_idm1341156544" role="bascode" localize="false"> MsgBox Pgm &amp; " " &amp; Var, , VENUS &amp;" and "&amp; MARS</paragraph>
+ <paragraph id="par_idm1341155296" role="bascode" localize="false">End Sub</paragraph>
</bascode>
-</body>
+<section id="relatedtopics">
+ <paragraph role="paragraph" id="par_id111593694878677"><link href="text/sbasic/shared/enum.xhp" name="Enum">Enum</link> statement</paragraph>
+ <paragraph role="paragraph" id="par_id111953694878677"><link href="text/sbasic/shared/03090413.xhp" name="Enum">Type</link> statement</paragraph>
+</section>
-</helpdocument>
+</body>
+</helpdocument> \ No newline at end of file