From QB64 Wiki
Revision as of 02:57, 11 February 2013 by imported>Clippy
Jump to navigation Jump to search

_DEFINE defines a range of variable names according to their first character as a datatype.


_DEFINE letter[-range, ...] AS [_UNSIGNED] datatype



  • When a variable has not been defined or has no type suffix, the value defaults to a SINGLE floating point value.
  • _DEFINE sets the variable types of all letters or letter ranges as encountered in the program flow(even in statement blocks not executed and all subsequent SUB procedures).
  • NOTE: Many Qbasic keyword variable names CAN be used with a STRING suffix($) ONLY! You CANNOT use them without the suffix, use a numerical suffix or use DIM, REDIM, _DEFINE, BYVAL or TYPE variable AS statements!
  • Qbasic's IDE may add DEF statements before any SUB or FUNCTION. QB64(like QB) will change all variable types in subsequent sub-procedures to that default variable type without giving a "Parameter Type Mismatch" warning or adding the proper DEF statement to subsequent procedures! If you do not want that to occur, either remove that DEF statement or add the proper DEF type statements to subsequent procedures. May also affect $INCLUDE procedures!

Example: Defining variables that start with the letters A, B, C or F as unsigned integers, including the Add2 FUNCTION.

_DEFINE A-C, F AS _UNSIGNED INTEGER PRINT Add2(-1.1, -2.2) END FUNCTION Add2 (one, two) Add2 = one + two END FUNCTION


Explanation: Unsigned integers can only return positive values while ordinary integers can also return negative values.

See also

Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page