What is this instruction in SCL in TIA Portal
Limit is defined as a constant =7
What does this mean FOR #index := #LIMIT TO 1 BY -1 DO especially the part BY -1 DO
Limit to 1 means we start at 7,6,5,4,3,1 and move to 1, but i dont understand what this ( BY -1) mean does it tell it to reduce -1 each time
(* Part 1 Sorting of data ******************************************************
Swaps adjacent pairs of values using the ”bubble sort”
method until the measured data buffer is correctly sorted. *)
REPEAT
#swap := FALSE;
FOR #index := #LIMIT TO 1 BY -1 DO
IF #sortbuffer[#index -1 ] > #sortbuffer[#index] THEN
#aux := #sortbuffer[#index];
#sortbuffer[#index] := #sortbuffer[#index -1 ];
#sortbuffer[#index -1] := #aux;
#swap := TRUE;
END_IF;
END_FOR;
UNTIL NOT #swap
END_REPEAT;
(* Part 2 Calculation of results ***********************************************
Calculates square root using standard function SQRT and
square using function SQUARE. *)
FOR #index := 0 TO #LIMIT BY 1 DO
#valr := INT_TO_REAL(#sortbuffer[#index]);
#resultr := SQRT(#valr);
#calcbuffer[#index].squareroot := REAL_TO_INT(#resultr);
#calcbuffer[#index].square := "SQUARE" (#sortbuffer[#index]);
END_FOR;
Limit to 1 means we start at 7,6,5,4,3,1
it is mean with BY operand only
FOR #index := (start_value) TO (end_value) BY (step) DO
operand FOR not compare between start_value & end_value, and cannot know if increment or decrement the start_value
29.06.2020 wrote:Update 2 for TIA Portal contains the following improvements and changes for SCL : SCL: Derived data types in arithmetic expressions
The rules for derived data types have been standardized. It is now no longer permitted to use these data types in arithmetic expressions in SCL. Example:
The following expression is no longer permissible in V16 Update 2: #myInt := #myHW_IO + 5;
In such cases, use a temporary tag of the basic data type: