Difference between revisions of "Documentation/BASIC Guide/Constants"
From Apache OpenOffice Wiki
< Documentation | BASIC Guide
Line 10: | Line 10: | ||
Constants are values which may be used but not changed by the program. | Constants are values which may be used but not changed by the program. | ||
== Defining Constants == | == Defining Constants == | ||
− | In {{ | + | In {{AOo}} Basic, use the keyword <tt>Const</tt> to declare a constant. |
<source lang="oobas"> | <source lang="oobas"> | ||
Line 49: | Line 49: | ||
== Predefined Constants == | == Predefined Constants == | ||
− | {{ | + | {{AOo}} Basic predefines several constants. Among the most useful are: |
*<tt>True</tt> and <tt>False</tt>, for Boolean assignment statements | *<tt>True</tt> and <tt>False</tt>, for Boolean assignment statements | ||
*<tt>PI</tt> as a type <tt>Double</tt> numeric value | *<tt>PI</tt> as a type <tt>Double</tt> numeric value |
Revision as of 13:32, 27 January 2021
Constants are values which may be used but not changed by the program.
Defining Constants
In Apache OpenOffice Basic, use the keyword Const to declare a constant.
Const A = 10 Const B = A+5 Const Hi = "Hello World"
Scope of Constants
Constants have the same scope as variables (see Scope and Life Span of Variables), but the syntax is slightly different. A Const definition in the module header is available to the code in that module. To make the definition available to other modules, add the Public keyword.
Public Const one = 1
Predefined Constants
Apache OpenOffice Basic predefines several constants. Among the most useful are:
- True and False, for Boolean assignment statements
- PI as a type Double numeric value
Dim bHit as Boolean bHit = True Dim dArea as Double, dRadius as Double ' ... (assign a value to dRadius) dArea = PI * dRadius * dRadius
Content on this page is licensed under the Public Documentation License (PDL). |