/*If routine has completed previously then exit routine*/
IF DN THEN
TND();
END_IF;
/* Retrieve the size of the incomming array */
SIZE(ArrayIn,0,ArraySize);
/*Validate requested position to remove*/
IF (Position >= 0) AND (Position <= ArraySize-1) AND (ArraySize>1) THEN
ER:=0;
/*Set destination data to extract array element*/
Destination:=ArrayIn[Position];
/*Calculate the array positions to operate on*/
CopyStart:=Position+1;
CopyLength:=ArraySize-(Position+1);
ClearStart:=10;
/*Validate there is something to copy*/
IF CopyLength >0 THEN
CPS(ArrayIn[CopyStart], ArrayIn[Position], CopyLength);
ArrayIn[ArraySize-1]:=0;
ELSIF CopyLength = 0 THEN
ArrayIn[ArraySize-1]:=0;
END_IF;
DN:=1;
ELSE
ER:=1;
END_IF;