Is it possible to use a loop inside a case.
Example: If I start the forloop in case 0, then in case 10 I add +1 to the forloop..?
I cant make the following work.
case steps of
0:
FOR Index := 1 TO 9 DO
IF LoadConveyerReady THEN
PickNPlaceArr[Index] := TRUE;
steps := 10;
10:
IF Packageplaced THEN
index := index +1
steps := 0;
END_IF
END_FOR
Hi, you can't use one FOR Loop and one IF in different CASE's. In your code, the "10" is inside FOR loop and IF statment, it is not part of CASE. You must put END_IF to end IF and END_FOR to end FOR loop, and after that "10" will be part of CASE. But you must do this before "10".
Hey thank u! But i wanted the forloop to end after case 10. So it starts in case 0, and ends in case 10. Here the loop will do all loops in case 0..
On the first question "Is it possible to use a loop inside a case." -> Yes!
But i think example code is not correct:
1.Cannot use FOR loop in different CASE (0 and 10).
2. You don't have "END_IF" on the CASE 0.
I rewrite your code, but i am not sure it is work correctly.
CASE "steps" OF
0:
FOR "Index" := 1 TO 9 DO
IF "LoadConveyerReady" THEN
#PickNPlaceArr["Index"] := TRUE;
"steps" := 10;
END_IF;
END_FOR;
10:
IF "Packageplaced" THEN
"Index" := "Index" + 1;
"steps" := 0;
END_IF;
END_CASE;