Boolean
See Also: Declaring Variables, Variable Declaration Commands, Struct, Boolean Expressions
Purpose
Declares one or more Boolean variables.
Syntax
To declare Boolean variables
Boolean {identifier} [… {identifier}]
Where:
- {identifier} is the name of a Boolean type variable. The first {identifier} is required.
- {identifier} may be between 1 and 4096 characters in length, must start with a letter, and may not contain spaces. Recommended characters are 0-9, a-z, A-Z, and _ (underscore).
To declare array variables of type Boolean
Boolean {dimension-list} {identifier} [… {identifier}]
Where:
- {dimension-list} is a list of one or more array dimensions for the array. A dimension list is declared using square brackets []. One pair of brackets is used to declare each dimension. If the array is static, then you must specify the static size of each dimension between each pair of brackets, e.g., [{size}]. For more information about declaring arrays, refer to Array Variable Assignments.
- {identifier} may be between 1 and 4096 characters in length, must start with a letter, and may not contain spaces. Recommended characters are 0-9, a-z, A-Z, and _ (underscore).
What It Does
The Boolean command declares Boolean variables. Multiple variables may be declared on one command line, with their names separated from each other by spaces.
Examples
Procedure Test
Boolean bSmoker bMarried bEmployed
Move False To bSmoker
Move False To bMarried
Move True To bEmployed
End_Procedure // Test
This example declares 3 Boolean variables: bSmoker, bMarried, and bEmployed, and initializes their values.
Boolean[] bPassFail
This example declares 1 dynamic array variable, named bPassFail, containing an undefined number of elements of type Boolean.
Boolean[5] bPassFail
This example declares 1 static array variable, named bPassFail, containing 5 elements of type Boolean.
Boolean[][3] bPassFail
This example creates a two-dimensional dynamic array variable named bPassFail, containing an undefined number of elements of type Boolean. Conceptually, this represents a rectangular array with an undefined number of rows, each of 3 columns.
You can declare dynamic multi-dimensional arrays where all dimensions are dynamic; these are called jagged arrays.
Notes
- The Boolean type is a simple type that is used for declaring variables for storing Boolean values. Boolean values are denoted by the predefined constants
TrueandFalse. - The Integer value of
Falseis 0 and the Integer value ofTrueis 1. - If you need to define a global Boolean variable, you should use the global_variable command to do so.