Numeric Equates

<< Click to Display Table of Contents >>

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.

A numeric equate (constant) must start with % sign.


Equates data type


Equates declaration has the following syntax:


%EquateName = NumericExpression [As NumericDataType]


Equal sign is optional, so the above sentence can also be written as:


%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:




%MINIMUM_L  = &H80000000 As Long


%Normal   = &B000000

%ReadOnly = &B000001

%Hidden   = &B000010

%System   = &B000100

%vLabel   = &B001000

%SubDir   = &B010000

%Archive  = &B100000


Hex numbers can be also represented using C notation 0x... followed by the hex representation of the hex value.




%MINIMUM_L  = 0X80000000 As Long




Some equate declaration example:



%NPARAM    = 3

%NTYPE     = 1

%RANK      = 2

%FILE      = 3

%KING      = 1

%PAWN      = 2







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