Chapter 5. Data Types
65
5.2 Variables
A variable is a symbolic name that refers to a unit of data storage. The contents of a variable
can change during program execution.
5.2.1 Types of Variables according to Format
Variables are classified into two types: string variables and numeric variables, each of which is
subclassified into non-array and array types.
Array variables should be declared in any of the
DIM
,
COMMON
, and
DEFREG
statements.
Note that the
DIM
statement should precede statements that will access the array variable.
BHT-BASIC can handle array variables up to two-dimensional.
The subscript range for an array variable is from 0 to 254.
[ 1 ] String Variables
A string variable should consist of 1 through 255 characters.
• Non-array string variables
A non-array string variable should be formatted with an identifier followed by a dollar sign
($) as shown below.
Syntax:
identifier$
Example:
a$,bcd123$
The default number of characters for a non-array string variable is 40.
• Array string variables
An array string variable should be formatted with an identifier followed by a dollar sign ($)
and a pair of parentheses () as shown below.
Syntax:
identifier$(subscript[,subscript])
Example:
a$(2),bcd123$(1,3)
Where a pair of parentheses indicates an array.
The default number of characters for an array string variable is 20.
Classification of Variables
Example
String variables
Non-array type
ab3$
Array type
One-dimensional
Two-dimensional
e$ (10)
gh$ (1,3)
Numeric variables
Integer variables
Non-array type
a%
Array type
One-dimensional
Two-dimensional
e% (10)
fg% (2,3)
Real variables
Non-array type
a,bcd
Array type
One-dimensional
Two-dimensional
e (10)
fg (2,3)
Summary of Contents for BHT-BASIC 100 SERIES
Page 1: ......
Page 161: ...153 Chapter 10 Sleep Function CONTENTS 10 1 Sleep Function 154...
Page 163: ...155 Chapter 11 Resume Function CONTENTS 11 1 Resume Function 156...
Page 173: ...165 Chapter 13 Backlight Function CONTENTS 13 1 Backlight Function 166...
Page 249: ...241 Example CLOSE IF kyIn Y THEN KILL Master Dat END IF Reference Statements CLFILE...