sysGetVariableString
Valid for: CANoe DE • CANoe:lite DE • CANoe4SW DE • CANoe4SW:lite DEFunction Syntax
long sysGetVariableString(char namespace[], char variable[], char buffer[], long bufferSize); // form 1long sysGetVariableString(SysVarName, char buffer[], long bufferSize); // form 2
Description
Returns the value of a variable of the String (char[]) type. Note- Direct access to values from system variables. An access to the whole string is with this variant not possible.
-
The function can also be used for specific elements of a system variable of type struct or generic array. For this, add the element to the name of the variable. If you directly give the element name to the function instead of using strings, precede the name by sysvarMember:: instead of sysvar::.
Example:
sysvarMember::SomeNamespace::SomeStructVariable.SomeArrayMember[0]
Parameters
- namespace: Name of the namespace.
- variable: Name of the variable.
- buffer: Buffer that takes the value of the variable.
- bufferSize: Size of the buffer.
- SysVarName: Name of the fully qualified name of the system variable, including all namespaces, separated by ”::”. The name must be preceded by “sysVar::”.
Return Values
- 0: no error, function successful
- 1: namespace was not found or second try to define the same namespace
- 2: variable was not found or second try to define the same variable
- 3: no writing right for the namespace available
- 4: the variable has no suitable type for the function
Example
Example 1sysGetVariableString(sysvar::MyNamespace::StringVar, buf, elcount(buf));
Example 2
This example shows the use of system variable types as a return value of functions and as a local variable.
The user-defined CAPL function getSysVarString returns any system variable of type String. The function is therefore defined with the system variable type sysvarString as the return value.
The system variable sv1 (defined with system variable type String) represents any system variable depending on the counter of the getSysVarString function.
The value of a system variable is set with the CAPL function sysSetVariableString.
The value of the system variable is get with the CAPL function sysGetVariableString and output in the Write Window.
Note
You must define the system variables FMW1::KeyString, DCM::SpeedSignalString, and Engine::EngineString in the System Variables Configuration dialog first.