RemoveVariable

Removes a user-defined variable.

Syntax

KsError RemoveVariable(
     HANDLE hVariable
);

Parameters

hVariable: the variable you want to remove.

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

User variables cannot be deleted using RemoveVariable when Debug functions are used.

Usable EtherCAT states

ecatOffline, ecatInit, ecatBoot, ecatPreOP, ecatSafeOP, ecatOP

Example

Copy
// Add an user variable in the variable table
UserVariable addVariable = { 0, L"User Control Flag", NULL, logBool };
nRet = AddVariable(&addVariable);
bool *ctrlFlag = (bool*)addVariable.Value;

if (nRet == errNoError)
{
    // Access the user variable in you application
    *ctrlFlag = true;
}

// Remove the variable if you are not going to use it anymore
nRet = RemoveVariable(addVariable.Id);

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

GetVariables