Shift in and compress data
This FP instruction shifts in data to the smallest address of the specified data table and compresses the data in the table toward the higher address.
Input
Data to be shifted in
Output
Starting address of area that is compressed into which data from s is shifted
Ending address of area where data is compressed
The data in the table specified by d1_Start and d2_End is rearranged as follows:
Data specified by s is shifted in to the area specified by d1_Start (starting address).
Non-zero data is shifted (compressed) in sequential order, in the direction of the higher address in the specified range.
Starting area d1_Start and ending area d2_End should be the same type of operand.
d1_Start must be £d2_End
If the content of s is "0", only a compressed shift is carried out.
if the area specified using the index modifier exceeds the limit.
if the address of the variable at input s1_Start > s2_End
if s1_Start and s2_End belong to different data areas.
if the area specified using the index modifier exceeds the limit.
if the address of the variable at input s1_Start > s2_End
if s1_Start and s2_End belong to different data areas.
Corresponding F instructions: F99_CMPW
All input and output variables used for programming this function have been declared in the POU header.The same POU header is used for all programming languages.
VAR
bStart: BOOL:=FALSE;
aiDataField: ARRAY [0..5] OF INT:=[555,444,0,11,0,10];
iShiftinData: INT:=32;
END_VAR
When the variable bStart is set to TRUE, the function is carried out.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 7 ;
NETWORK_BODY
B(B_F,FP_DATA_WRITE_COMPRESS!,,9,1,23,6,,?DEN?D@'s'?AENO?Cd1_Start?Cd2_End);
B(B_CONTACT,,bStart,5,2,7,4,);
B(B_VARIN,,iShiftinData,7,3,9,5,);
B(B_VAROUT,,aiDataField[0],23,3,25,5,);
B(B_VAROUT,,aiDataField[5],23,4,25,6,);
L(1,3,5,3);
L(7,3,9,3);
L(1,0,1,7);
END_NETWORK_BODY
END_NET_WORK
END_BODY
If (bStart) then
FP_DATA_WRITE_COMPRESS(s := iShiftinData,
d1_Start => aiDataField[0],
d2_End => aiDataField[5]);
End_if;