CAPL Script

GetValue

This reference collection includes Vector documentation reproduced with permission. Snippets may require configuration-specific symbols and are not all standalone programs. Sources and validation limits.

Syntax

int getValue(EnvVarName); // form 1

float getValue(EnvVarName); // form 2

long getValue(EnvVarName, char buffer[]); // form 3

long getValue(EnvVarName, byte buffer[]); // form 4

long getValue(EnvVarName, byte buffer[], long offset); // form 5

float getValue(char name[]); // form 6

long getValue(char name[], char buffer[]); // form 7

long getValue(char name[], byte buffer[]); // form 8

long getValue(char name[], byte buffer[], long offset); // form 9

Function

Determines the value of the environment variable with identifier EnvVarName/name. The type of the return value is based on the type of environment variable (int for discrete (form 1), float for continuous environment variables (form 2 and 6)). For character string environment variables (form 3 and 7) and environment variables with data bytes (form 4, 5, 8 and 9) the active value is saved to a buffer which you identify in the function call.

Parameters

EnvVarName Environment variable name.Must exist in the database.

buffer

Return buffer (form 3, 4 and 5)

offset

Offset of the first data byte copied (form 5)

Return Values

Form 1 and 2 Active value of the environment variable.

Form 3, 4 and 5

Number of bytes copied.

int val;
float fval;
char cBuf[25];
byte bBuf[64];
long copiedBytes;
// These environment-variable names must exist in the configuration.
val = getValue(Switch);
fval = getValue(Temperature);
copiedBytes = getValue(NodeName, cBuf);
copiedBytes = getValue(DiagData, bBuf);
copiedBytes = getValue(DiagData, bBuf, 32);

Related reference: getValueSize | putValue | Direct access to values from system variables