strMid (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

ALL

Firmware version:

1.00 / 1.00.00


strMid will return a specified sub-string from a string.

 

Note that the returned string is a dynamic string.

 

Input:

str : STRING

String that is to be extracted from.

 

start : INT

Start position from the left for extracted string.

 

length : INT Default 999

Number of characters to return from the "start" position. If not assigned, then the rest of 'str' is returned.

 

Returns: STRING

The extracted string.

 

Declaration:

FUNCTION strMid : STRING;
VAR_INPUT
  str   : STRING;
  start : INT;
  length : INT := 999;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
VAR
  result : STRING;
END_VAR;
 
PROGRAM test;
 
BEGIN
  ...
result := strMid(str:="hello world", start:=4, length:=2);
  // result will contain "lo" after the call
  ...
END;
 
END_PROGRAM;