Syntax
defsng letter1 [-thruLtr1] [,letter2 [-thruLtr2]...]
defdbl letter1 [-thruLtr1] [,letter2 [-thruLtr2]...]
defstr letter1 [-thruLtr1] [,letter2 [-thruLtr2]...]
defint letter1 [-thruLtr1] [,letter2 [-thruLtr2]...]
deflong letter1 [-thruLtr1] [,letter2 [-thruLtr2]...]
Description
A def<type>
statement specifies the data type for subsequently occurring variables, arrays and record fields whose names begin with any of a specified set of letters. The def<type>
statement only applies to variables, arrays and record fields whose types are not otherwise explicitly declared that means you can override the effect of a def<type>
statement by putting a type-identifier suffix (like "%
" or "&`
") at the end of a name, or by declaring the name in a dim
statement using an as
clause.
Each of the letter
and thruLtr
parameters should be a letter of the alphabet. A def<type>
statement applies to those simple variables, arrays and record fields whose names begin with letter1
, letter2
, etc. Whenever a thruLtr
parameter is included, the statement also applies to names that start with any letter in the range between letter
and thruLtr
(inclusive). (For that reason, a thruLtr
parameter should always occur later in the alphabet than the letter parameter it's paired with.)
def<type>
statements are global in scope (that is, they apply to names declared both inside and outside of local functions). If you use def<type>
statements within your program, they should appear near the top of your source code. In particular, if a def<type>
statement appears farther down in the source than some variable, array or record field that it applies to, the results could be unpredictable.
def<type>
statements are "non-executable," which implies that they should not appear within any kind of "conditional execution" block, such as for...next
, if...end if
, do...until
, etc. (but they may be conditionally included or excluded if you put them inside a #if...#endif
block).
The following table indicates the default type applied by each of the def<type>
statements.
statement
|
default type
|
equivalent suffix
|
defsng
|
single precision
|
!
|
defdbl
|
double precision
|
#
|
defstr
|
string
|
$
|
defint
|
integer
|
%
|
deflong
|
long integer
|
&
|
See also
defstr long/word/byte; Appendix C - Data Types and Data Representation