DEFBYT, DEFCUR, DEFCUX, DEFDBL, DEFDWD, DEFEXT, DEFINT, DEFLNG, DEFQUD, DEFSNG, DEFSTR and DEFWRD functions

Purpose

Declare the default type for variable identifiers that begin with specified letters.

Syntax

DEFtype letter_range [, letter_range] [, ...]

Remarks

type represents one of PowerBASIC's variable types: INT (Integer), LNG (Long-integer), QUD (Quad-integer), SNG (Single-precision floating-point), DBL (Double-precision floating-point), EXT (Extended-precision floating-point), CUR (Currency), CUX (Extended-currency), STR (String), BYT (Byte), WRD (Word), and DWD (Double-word).

letter_range

is either a single alphabetic character (A through Z, case insignificant), or a range of letters (two letters separated by a hyphen, for example, A-M).

DEFtype

tells the compiler that variables and user-defined functions, whose names begin with the specified letter or range of letters, are of the specified type.

Normally, when the compiler finds a variable name without a type specifier, a compiler error is generated.  If however, there was a preceding DEFtype statement such as DEFINT A-Z, the variable would default to that type (in this case, an Integer variable).

You may use multiple DEFtype statements.  If there is overlap between two DEFtype statements, no error is generated; but the definition of the latter DEFtype statement overrides the former where the two overlap.

The DEFtype statement may not be supported in future editions of PowerBASIC, so we recommend explicit variable declarations, using DIM, LOCAL, STATIC, THREADED, or GLOBAL.

Restrictions

Deftype only applies to implicitly-defined variables. It has no effect on variables that are defined explicitly. If a #DIM ALL statement exists in the application then Deftype statements will have no affect, #DIM ALL requires all variables to be defined explicitly

Example

DEFINT A-E, G, Q, Y-Z

DEFCUX B, F, H-P, R-X

FUNCTION PBMAIN

  A = 1  ' A is Integer

  B = 2  ' B is Extended-currency.

  ...

END FUNCTION

See Also

#DIM ALL, DIM, LOCAL, STATIC, THREADED, GLOBAL