Have posted a more advanced version, EST.zip, that utilizes the same Control structure that you use with a FIFO Load / Unload pair. This will allow you to delete an element in the middle of an array, but keep the Control.POS value set to the correct location. This one I titled EST for Extract Stack. Latter I will add a LST for Load Stack so that an element can be loaded anywhere in the array structure. ================================================================= This Add-On was created in V19. It will allow you to select an element within an array, that element will be copied to a destination and then the elements below it will be moved up to fill in. The last element in the array will then be written to 0. The add-on is attached below as ArrayShift.zip.The main logic resembles: /*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; |
General Information > RSLogix 5000 >