strLookup (Functionblock)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

ALL

Firmware version:

1.00 / 1.00.00


strLookup will compare a string with up to 4 different strings and report if there is a match. The function is not case sensitive - so "Fox" and "fox" will be equal.

 

 

Input:

str : STRING

String that the function will try to match with str1, str2, str3, or str4.

 

str1 : STRING

String 1 that the function will compare with str.

 

str2 : STRING

String 2 that the function will compare with str.

 

str3 : STRING

String 3 that the function will compare with str.

 

str4 : STRING

String 4 that the function will compare with str.

 

Output:

match : INT (0..4)

0

if str matched none of str1, str2, str3, or str4.

1

if str is identical to str1.

2

if str is identical to str2.

3

if str is identical to str3.

4

if str is identical to str4.

 

Declaration:

FUNCTION_BLOCK strLookup;
VAR_INPUT
  str   : STRING;
  str1 : STRING;
  str2 : STRING;
  str3 : STRING;
  str4 : STRING;
END_VAR;
VAR_OUTPUT
  match : INT;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
VAR
  result : INT;
  search : strLookup;
END_VAR;
 
PROGRAM test;
 
BEGIN
  ...
 search(str:="fox", str1:="The", str2:="Quick", str3:="Brown", str4:="Fox");
  result := search.match;
  // result will contain 4 as the str matched the contents of str4 (Fox)
  ...
END;
 
END_PROGRAM;