beautypg.com

Const, Consttable/endconsttable – Campbell Scientific CR9000X Measurement and Control System User Manual

Page 173

background image

Section 5. Program Declarations

CONST

Declares symbolic constants for use in place of values.

Syntax

Const

constantname = expression [, constantname = expression] . . .

Remarks
THE CONST STATEMENT HAS THESE PARTS:

Part Description
constantname

Name of the constant.

expression

Expression assigned to the constant. It can consist of literals
(such as 1.0), other constants, or any of the arithmetic or logical
operators.

Tip

Constants can make your programs self-documenting and easier
to modify. Unlike variables, constants can't be inadvertently
changed while your program is running.

Caution

Constants must be defined before referring to them.

Tip

Use all uppercase letters for constant names to make them easy
to recognize in your program listings.

Const Declaration Example

The example uses Const to define the symbolic constant PI.

Const PI = 3.141592654 'Define

constant.

CONSTTABLE/ENDCONSTTABLE

Used to declare one or more constants that can be changed using the
CR1000KD keyboard display. The program is then recompiled with the new
values.

Syntax

ConstTable

Const A = value

Const B = value

EndConstTable

Remarks
The ConstTable declaration should appear in the declarations section of the
program, prior to the start of the main program. The intent of this declaration is
to define one or more constants in the program that will be listed in a special
table in the datalogger, and which can be edited using the CR1000KD
Keyboard display, and the program recompiled to use the new values.
Recompiling the program in this manner will reset the data tables stored in the
datalogger’s CPU and may make the Data Tables stored on a card unusable (if
the Data Table Header is changed), so all data should be collected before
editing a value in the constant table.

5-3