5.5.1 Implicit Data Typing
With implicit data typing, a data type for a variable is cre-
ated and specified the first time you reference it. You specify
the data type of the variable by a suffix on the variable name
as follows:
.
A percent sign suffix ( % ) specifies the INTEGER data
type.
.
A dollar sign suffix ( $ ) specifies the STRING data type.
.
Any other ending character specifies a variable of the
default data type.
The default data type is SINGLE; however, you can specify
your own default at DCL command level, inside the BASIC
environment, or with the OPTION statement in your pro-
gram. For more information about establishing default data
types, see Chapter 2 (VAX BASIC only) and Chapter 3 in this
manual, and the OPTION statement in the DEC BASIC and
VAX BASIC for OpenVMS Systems Reference Manual .
The first time the variable is referenced, it creates a variable
with that name and data type and allocates storage for that
variable.
In the following example, two INTEGER variables are cre-
ated, A% and B% . Even though the values assigned to these
variables are REAL, the values are converted to INTEGER to
match the data type specified for the variables. The sum of
these two values is therefore 30, not 30.6, as it would be if the
variables were named A and B .
A% = 10.1
B% = 20.5
PRINT A% + B%
30
With explicit data typing, you use a declarative statement to
name and specify a data type for your program values.