Difference between revisions of "DEFINE"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
imported>Clippy
m
Line 27: Line 27:
 
{{Cl|END FUNCTION}} '' ''
 
{{Cl|END FUNCTION}} '' ''
 
{{CodeEnd}}
 
{{CodeEnd}}
: ''Explanation:'' Any undefined variables that start with the letters A, B, C or F will now be defined as unsigned integers, including the ''Add2'' [[FUNCTION]]. Unsigned integers can only use positive values while ordinary integers can also use negative values.
+
: ''Explanation:'' Any undefined variables that start with the letters A, B, C or F will now be defined as unsigned integers, including the ''Add2'' [[FUNCTION]]. Unsigned integers can only return positive values while ordinary integers can also use negative values.
  
  

Revision as of 21:18, 21 September 2011

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


Syntax

_DEFINE range or letter[, range2 or letter2[, range3 or letter3[, ...]]] AS [_UNSIGNED] datatype


Description

  • Variable start letter range is in the form firstletter-endingletter (like A-C) or just a single letter.
  • Datatypes: INTEGER, SINGLE, DOUBLE, LONG, STRING, _BIT, _BYTE, _INTEGER64, _FLOAT
  • Can also use the _UNSIGNED definition for positive numerical values only.
  • 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:

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

Explanation: Any undefined variables that start with the letters A, B, C or F will now be defined as unsigned integers, including the Add2 FUNCTION. Unsigned integers can only return positive values while ordinary integers can also use negative values.



See also


Reference: Mathematical Operations



Navigation:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page