ConstTable/EndConstTable (Declare Constants)

The ConstTable/EndConstTable instructions are used to declare one or more constants that can be changed using software, the keyboard display, or the C command in terminal mode. The program is then recompiled with the new values.

Syntax

ConstTable ( TableName, Hidden ) ‘TableName and Hidden are optional parameters

          'declare constants

    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. The constants in this special table can be edited and the program recompiled to use the new values. In some instances, recompiling the program in this manner will reset the data tables in the datalogger, so all data should be collected before editing a value in the constant table.

The ConstTable provides a way to have a changeable value in an instruction parameter that requires a constant (for instance, the interval for the Scan instruction will not accept a variable). For users who are familiar with CR10X, CR23X, and CR510 dataloggers, the ConstTable is similar to the *4 Table functionality.

There are three different options that can be used to set up a constant table using this instruction.

Option 1, no parameters

ConstTable

          ‘define constants

EndConstTable

This option sets up a table in the datalogger’s menu system named Constant Table. The menu system is accessed using the datalogger’s terminal emulatorkeyboard display, and the table is found under the Configure, Settings menu. Once changes have been made, set the Boolean value ApplyAndRestart to True to effect the changes (after the changes are made, the Boolean value is reset to False). The constants in the constant table can be edited using terminal emulation by entering a C at the datalogger prompt. Once changes have been made, enter Y to save the changes and recompile the program.

Option 2, table name

ConstTable ( TableName ) ‘where TableName is the name you want to assign

          ‘define constants

EndConstTable

This option sets up a constant table in the datalogger with a custom name and enables the table to be displayed and edited in the numeric monitor or table monitor found in datalogger support software. Set ApplyAndRestart to True to effect the changes. The constant table can also be edited using terminal emulation mode. Note that TableName cannot be any of the predefined table names in the datalogger; for example, Public, Status, Settings, or DataTableInfo.

Option 3, hidden custom table

ConstTable ( TableName, 1 ) ‘where TableName is the name you want to assign

          ‘define constants

EndConstTable

This option sets up a constant table in the datalogger with a custom name and enables the table to be displayed and edited in the numeric monitor or table monitor found in datalogger support software. However, in order for the table to be displayed in software, the user must connect to the datalogger with the highest level of security (the "hidden" table is still visible using the keyboard display). Set ApplyAndRestart to True to effect the changes. The constant table can also be edited using terminal emulation mode. Note that TableName cannot be any of the predefined table names in the datalogger; for example, Public, Status, Settings, or DataTableInfo.

Usage notes

When a constant table is edited in the datalogger, the datalogger must first make a copy of the program in memory. Thus, there must be enough available memory to hold two copies of the program until the new one is compiled. If the datalogger’s memory is too small, the operation will fail. This can occur with large programs, with smaller memory dataloggers, or if too many files are stored on the datalogger's CPU drive. In the case of too many files, delete unnecessary files to free up memory.

Constants input using the keyboard display or software can be validated before they are compiled and used in the program by using the ApplyandRestartSequence/EndApplyandRestartSequence declaration. This declaration defines code that will be run prior to setting the new constant values in the program.

Constants can be changed under program control using the SetSettings instruction. The ConstTable must be a custom-named ConstTable in the program (e.g., Option 2 discussed previously). All defined constants in the table, as well as the ApplyAndRestart field, can be set in this way.

SetSetting ( “ConstTableName.ConstantName”, Value )

As an alternative to the ConstTable declaration, the datalogger can be programmed to provide a custom menu item for changing a value in the constant table. This is accomplished using MenuItem, MenuPick, and MenuRecompile. See MenuRecompile for details and an example program. Custom menus are not accessible via datalogger software.