The DVM editor provides a wealth of options for evaluating and processing strings.
String functions can be recognized directly by their orange color.
The functions can be found in the menu on the left under “Text”:
Overview of all string functions
An important basic rule is that string functions can’t be nested – a variable must always be assigned directly.
These fields are used to insert static strings (orange) or characters (pink) directly into program sequences.
This function joins two strings or characters.
Output format: String
Cuts “x” characters from position “y” from the specified string.
Output format: String
Determines the length of the string.
Output format: Number
Determines the position of the second string within the first string.
Output format: Number
Converts a string with decimal or hexadecimal content into a number.
Output format: Number
Converts a number into a decimal or hexadecimal string.
Output format: String
Compares two strings.
Returns “0” if both strings are the same, “1” if Text1 is greater than Text2 or “2” if Text1 is less than Text2.
Output format: Number
Used to describe text variables. This function can be found in the “Variables” menu.
Example for evaluating a device response
In the following example, the power status of a projector is queried and evaluated:
In the start phase and also in the shutdown phase, the application queries the projector for its status every two seconds using the character string ‚PWR?‘.
The RS232 interface is first queried via the number variable ‚input‘. As soon as characters are stored in the buffer of the interface, ‚input‘ is > ‚0‘. Now the characters from the contents of the buffer are written to the variable ‚inputChar‘, joint to the variable ‚response‘ and evaluated.
If the response from the projector indicates that it is ready for operation (‚PWR=01‘) or in standby (‚PWR=09‘), the respective numeric variable is set to ‚0‘ and can be evaluated.
The ‚:‘ stands for the end of the string. The variable ‚response‘ will be reset if this is contained in the string.