Const

From NSB App Studio
Revision as of 04:08, 29 June 2012 by Brendon (talk | contribs) (Created page with "CONST ''name''=''expression'' '''Description''' CONST declares constants, which can be used in expressions, in place of literal values. The required component, ''name'', mus...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

CONST name=expression

Description

CONST declares constants, which can be used in expressions, in place of literal values. The required component, name, must follow standard variable naming conventions. The required component, expression, is any literal, constant, or combination that includes all arithmetic or logical operators (except IS).

All constants declared inside procedures are available only within the procedure. CONST works the same way as DIM, however it is used to identify variables whose value should not be changed.

Multiple constants may be declared on a single line, by separating each constant assignment with a comma.

Example

REM CONST Example
'CONST defines constants
CONST SHAPE = "Rectangle"
CONST AREA = 51
CONST LENGTH = 7, WIDTH = 11
PrintArea LENGTH, WIDTH
SUB PrintArea(l, w)
  DIM Area
  Area = l * w
  PRINT SHAPE & " area: " & l & " * " & w &" = " & Area
END SUB

Output

Rectangle area:7*11=77

Related Items

FUNCTION, DIM, SUB