FUNCTION "FC_TSHR_Shift" : Void
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
   VAR_INPUT 
      xInShiftBack : Bool;
   END_VAR

   VAR_IN_OUT 
      arTSHR : Array[*] of "stCarrier";
   END_VAR

   VAR_TEMP 
      tStatus : Int;
      tStatusSim : Int;
      tSrcIdx : DInt;
      tDestIdx : DInt;
      nArrayMax : DInt;
      stEmptyCarrier : "stCarrier";   // Carrier mit leeren Daten
   END_VAR

   VAR CONSTANT 
      Constant_1 {InstructionName := 'DTL'; LibVersion := '1.0'} : DTL;
   END_VAR


BEGIN
	#nArrayMax := UPPER_BOUND(ARR := #arTSHR, DIM := 1);            // get array size
	
	IF #xInShiftBack THEN                                           // move backward
	    #tSrcIdx := 1;
	    #tDestIdx := 0;
	ELSE                                                            // move forward
	    #tSrcIdx := 0;
	    #tDestIdx := 1;
	END_IF;
	
	#tStatus := MOVE_BLK_VARIANT(SRC := #arTSHR,
	                             COUNT := DINT_TO_UDINT(#nArrayMax-1),
	                             SRC_INDEX := #tSrcIdx,
	                             DEST_INDEX := #tDestIdx,
	                             DEST => #arTSHR);
	
	#arTSHR[#nArrayMax] := #stEmptyCarrier;
	
	
	
	
	
END_FUNCTION

