2 - 12 2 - 12
MELSEC-Q
2 THE BASICS OF AD51H-BASIC
2.8 Variables
Variables are names that are used to represent values used within BASIC programs.
Values of variables can be defined by the programmer or assigned as calculation
results. The values of numeric variables are 0 and values of character string variables
are empty character strings until their proper values are defined.
2.8.1 Variable names and type declaration characters
Variable names are subject to the following restrictions:
• The length of variable names within BASIC is restricted to a maximum of 15
characters.
• Variable names must be comprised of alphanumeric characters. Periods are also
valid.
• The first character of a variable name must be an alphabet character.
• Special characters (%, !, #, $) may be used as a type declaration character.
• Reserved words cannot be used for variable names, but reserved words may be
used as a portion of a variable name.
Reserved words include all instruction, function, and operator names.
• If a variable name begins with FN, it is considered to be a call to a user-defined
function.
• Variables represent either numeric values or character strings.
• The last character of a character string variable name must be a dollar sign ($).
For example, in A$=”SALESREPORT”, the dollar sign is a variable declaration
character, and “declares” that the variable represents a character string.
• Numeric variable names can be declared as single-precision, double-precision, or as
integers.
• There are the following types of declaration characters for variable names.
%
Integer variables
!
Single-precision variables
#
Double-precision variables
$
Character string variables
If a declaration character is omitted in a numeric variable name, it is assumed that the
variable represents a single-precision numeric value.
The following are some examples of variable names.
Example
PI#
• • • • •
Declares a double-precision variable.
MINIMUM!
• • • • •
Declares a single-precision variable.
LIMIT%
• • • • •
Declares an integer variable.
N$
• • • • •
Declares a character string variable.
ABC
• • • • •
Declares a single-precision variable.
The variable type can also be declared using DEFINT, DEFSTR, DEFSNG, and
DEFDBL within programs.