Navigation: thinBasic language > Data types and variables > Numeric Equates |
|
Numeric equates
thinBasic allows you to refer to numeric constants by name. Those constant values are called equates.
Equates data type
Equates declaration has the following syntax:
%EquateName = NumericExpression [As NumericDataType]
Where the optional parameter NumericDataType can be any of the allowed numeric data types: BYTE, INTEGER, WORD, DWORD, LONG, QUAD, SINGLE, DOUBLE, EXTENDED, CURRENCY.
If not NumericDataType is specified, default type will be assumed to be LONG.
Binary and hex numbers can be represented indicating &B or &H followed by the relative representation. Examples:
%MAXIMUM_D = &HFFFFFFFF As DWORD
%MAXIMUM_L = &H7FFFFFFF As Long
%MINIMUM_L = &H80000000 As Long
%Normal = &B000000
%ReadOnly = &B000001
%Hidden = &B000010
%System = &B000100
%vLabel = &B001000
%SubDir = &B010000
%Archive = &B100000
Examples
Some equate declaration example:
%MAXPIECES = 32
%NPARAM = 3
%NTYPE = 1
%RANK = 2
%FILE = 3
%KING = 1
%PAWN = 2
%MAXVALUE = 0.999 AS EXT
%ANYVALUE = 0.999 AS DOUBLE
Restrictions
1. | Numeric equates name must start with percent sign % |
2. | Unlike variables, you can use an equate on the left side of an assignment statement only once. |
3. | If an equate has already been created, subsequent attempts to assign a new value will fail but no error will be generated |
© 2004-2008 thinBasic. All rights reserved. | Version 1.7.0.0 | Web Site: http://www.thinbasic.com |