FUNCTION FC 1 : VOID
TITLE =
VERSION : 0.1
VAR_INPUT
InputString : STRING [254 ];
END_VAR
VAR_TEMP
TempString : STRING [254 ];
iLoopCount : INT ;
iDBNumber : INT ;
END_VAR
BEGIN
NETWORK
TITLE =
L P##InputString;
LAR1 ;
L W [AR1,P#0.0]; //DB number of input string
T #iDBNumber;
L D [AR1,P#2.0]; //area pointer of input string
LAR1 ;
L 0;
L #iDBNumber; //if DB number = 0 then don't open DB
==I ;
JC nodb;
OPN DB [#iDBNumber]; //else open correct DB for Input string
nodb: L B [AR1,P#0.0]; //get string max length
+AR1 P#1.0;
L B [AR1,P#0.0]; //get string actual length
+AR1 P#1.0;
LAR2 P##TempString; //point to temp string
T B [AR2,P#1.0]; //set actual length of temp string
TAK ;
T B [AR2,P#0.0]; //set max length of temp string
TAK ;
+AR2 P#2.0; //update ar2 to pint to first char
L 0; //actual length = 0 ?
==I ;
JC Exit; //if so then exit
TAK ;
Lop1: T #iLoopCount;
L B [AR1,P#0.0]; //copy char from input string..
T B [AR2,P#0.0]; //..to temp string
+AR1 P#1.0; //index to next
+AR2 P#1.0; //index to next
L #iLoopCount; //until all done
LOOP Lop1;
Exit: NOP 0;
END_FUNCTION