GetVariables

Gets the list of user-defined variables.

Syntax

KsError GetVariables(
     int BufferLength,
     int* VariableCount,
     UserVariable* Buffer
);

Parameters

BufferLength: the length of the buffer that stores the variables.

VariableCount: the number of the variables read.

Buffer: pointer to the buffer where the variable list will be read. See the UserVariable structure.

Return value

If the function succeeds, it returns errNoError, otherwise an error code. For more information about the error code, see the KsError list.

Remarks

The variables can be used in KINGSTAR Scope and a real-time log.

Usable EtherCAT states

ecatOffline, ecatInit, ecatBoot, ecatPreOP, ecatSafeOP, ecatOP

Example

Copy
int varCount = 0;

// The buffer length depends on how many variables you added. It can be shorter.
const int bufLength = 64;

UserVariable *variableTable = (UserVariable*)malloc(bufLength * sizeof(UserVariable));

// Get all variable information at once
nRet = GetVariables(bufLength, &varCount, variableTable);
if (nRet == errNoError)
{
    // Access the user variables in you application
}

Requirements

  RT Win32
Minimum supported version 4.1 4.1
Header ksapi.h ksapi.h
Library KsApi_Rtss.lib KsApi.lib

See also

AddVariable

GetVariable

RemoveVariable