Function(还没弄完...等下继续) |
"LSOR" SORTING BLOCK
1 : Ascending -1: Descending
|
Example |
[‘4‘,‘1‘,‘9‘,‘8‘,‘2‘,‘10‘,‘3‘,‘7‘,‘6‘,‘5‘] => [‘1‘,‘2‘,‘3‘,‘4‘,‘5‘,‘6‘,‘7‘,‘8‘,‘9‘,‘10‘]//Ascending |
[‘4‘,‘1‘,‘9‘,‘8‘,‘2‘,‘10‘,‘3‘,‘7‘,‘6‘,‘5‘] => [‘10‘,‘9‘,‘8‘,‘7‘,‘6‘,‘5‘,‘4‘,‘3‘,‘2‘,‘1‘]//Descending |
Parameter |
Input
Output
InOut
Static
CA Array[0..9] of Char DI UDInt CA2 Array[1..10] of Char
Temp
Constant
|
Programming |
#DI := "LCA_DI"(#CA);
"LDI_CA"(INUM := #DI,
OCHR => #CA2);
|
Result |
|
Library |
"LCA_DI" Convert Char Array to DInt |
Parameter |
Input ICHR Array[*] of Char Output
InOut
Temp TI Int TMOD_NUM DInt TTOL_NUM UDInt TONE_NUM DInt TUP_BOU Int TLW_BOU Int Constant
Return LCA_DI UDInt
|
Programming |
#TTOL_NUM := 0;
#TONE_NUM := 0;
#TMOD_NUM := 1;
#TUP_BOU := DINT_TO_INT(IN := UPPER_BOUND(ARR := #ICHR, DIM := 1));
#TLW_BOU := DINT_TO_INT(IN := LOWER_BOUND(ARR := #ICHR, DIM := 1));
FOR #TI := #TUP_BOU TO #TLW_BOU BY -1 DO
#TONE_NUM := INT_TO_DINT(ABS(CHAR_TO_INT(#ICHR[#TI])) - 16#30);
IF #TONE_NUM < 0 OR #TONE_NUM > 9 THEN
#TONE_NUM := 0;
END_IF;
#TTOL_NUM := #TTOL_NUM + DINT_TO_UDINT(#TONE_NUM * #TMOD_NUM);
#TMOD_NUM := #TMOD_NUM * 10;
END_FOR;
#LCA_DI := #TTOL_NUM;
|
"LDI_CA" Convert DInt to Char Array |
Parameter |
Input INUM UDInt Output OCHR Array[*] of Char InOut
Temp TI Int TCHR Char TMOD Int TMOD_NUM UDInt TUP_BOU Int TLW_BOU Int Constant
Return LDI_CA Void
|
Programming |
#TMOD := 0;
#TMOD_NUM := 1;
#TUP_BOU := DINT_TO_INT(IN := UPPER_BOUND(ARR := #OCHR, DIM := 1));
#TLW_BOU := DINT_TO_INT(IN := LOWER_BOUND(ARR := #OCHR, DIM := 1));
FOR #TI := #TUP_BOU TO #TLW_BOU BY -1 DO
#TMOD := UDINT_TO_INT((#INUM / #TMOD_NUM) MOD 10);
#OCHR[#TI] := INT_TO_CHAR(ABS(#TMOD) + 16#30);
#TMOD_NUM := #TMOD_NUM * 10;
END_FOR;
|
Video |
|
|
|
|
|