Action
Declares a symbolic constant.
Syntax
DIM symbol AS CONST value
New Syntax(compatible with QB/VB)
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) 1997-2001 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"
'Or use expressions
Const x = (A * B1) + sin(csingle) '
will end up as a single because of using singles.
Const
z1 = 1
Const Z2 = Z1 + 1
S = Csingle
Print S ; " " ; Cstring
Waitms A 'wait for
5 milliseconds
Print A
Print B1
End
|