CONST

Top  Previous  Next

Action

Declares a symbolic constant.

 

 

Syntax

CONST symbol = value

 

 

Remarks

symbol

The name of the symbol.

Value

The value to assign to the symbol.

 

Assigned constants consume no program memory.

The compiler will replace all occurrences of the symbol with the assigned value.

Value may also be an expression that uses other defined constants.

The functions that may be used for the expressions are : ASC , ABS, ATN, COS , EXP , FIX, INT , LOG, RND , SGN , SIN ,SQR , TAN.

Operators are : AND, OR ,XOR +, - , / , \ , ^ , * , NOT , > , < , = , >= , <=,<> , (, )

 

 

See also

DIM

 

 

Example

'----------------------------------------------------

'              (c) 1995-2006 MCS Electronics

'              CONST.BAS

'----------------------------------------------------

Dim A As Const 5                       'declare a as a constant

Dim B1 As Const &B1001

Dim S As Single

'Or use the new preferred syntax

Const Cbyte = &HF

Const Cint = -1000

Const Csingle = 1.1

Const Cstring = "test"

 

S = Csingle

Print S ; "  " ; Cstring

Waitms A                               'wait for 5 milliseconds

Print A

Print B1

End