beautypg.com

Section 5. program declarations, Alias – Campbell Scientific CR9000X Measurement and Control System User Manual

Page 171

background image

Section 5. Program Declarations

Constants (and pre-defined constants), Variables, Constants, Aliases, Units, Data
Tables, Functions, and Subroutines must be declared before being used in a
CRBasic program. They are normally declared at the beginning of a CRBASIC
program.

The Declarations instructions include:

Public

makes the variable available in the Public table

Dim

declares variables and variable arrays

Const

declares symbolic constants for use in place of numeric entries

Alias

assigns a second name to a variable

StationName sets the station name (up to 64 characters)
Units

assign a label to identify the units to a variable

Function

Declares a user defined Function.

Sub

Declares a Subroutine.

Data Tables must also be declared in the program, using the DataTable instruction,
prior to calling the Data Table from the body of the main program. Data Tables
and their structures are covered in Section 6

Data Table Declarations and

Output Processing Instructions

.

See Section 4.2.4 Declarations for additional Information.

ALIAS

Used to assign a second name to a variable.

Syntax

Alias VariableA = VariableB

Remarks
Alias allows assigning a second name to a variable. Within the datalogger
program, either name can be used. Only the alias is available for Public variables.
The alias is also used as the root name for datatable fieldnames.

With aliases the program can have the efficiency of arrays for measurement and
processing yet still have individually named measurements.

A swath of data can be Aliased by assigning a dimension to the AliasName

Example: ALIAS VariableName(3) = AliasName(2); will result in

VariableName(3) being aliased with AliasName(1)
VariableName(4) being aliased with AliasName(2)

Alias Declaration Example

The example shows how to use the Alias declaration.

Dim TCTemp(4)
Alias TCTemp(1) = CoolantT
Alias TCTemp(2) = ManifoldT
Alias TCTemp(3) = ExhaustT
Alias TCTemp(4) = CatConvT

5-1