FOR inside another FOR

Hello,

I was wondering how it is possible to include FOR inside of another FOR routine?
I have pick & place program where I need to pick parts from pallet to another pallet with different distances between parts.

In the following program it starts DropPart from the beginning, but PickPart works just fine when there is “RETURN;” at the end of DropPart.
Is it even possible to use “FOR” to this kind of work?


    CONST robtarget Pick:=[[233.88,20.36,-22],[0.0188622,0.999235,-0.0341801,-0.00240115],[1,-1,-1,4],[-176.75,9E+09,9E+09,9E+09,9E+09,9E+09]];
    CONST robtarget Drop:=[[194.41,87.15,-13.11],[0.018849,0.999236,-0.0341648,-0.00239745],[1,-2,-1,4],[-176.745,9E+09,9E+09,9E+09,9E+09,9E+09]];
    VAR num PickRow{8}:=[0,16,32,48,64,80,96,112];
    VAR num PickColumn{8}:=[0,16,32,48,64,80,96,112];
    VAR num DropRow{10}:=[0,14.5,29,54.5,69.5,88.3,103,127.3,142.5,157];
    VAR num DropColumn{4}:=[0,-12,-27,-39];

       PROC **PickPart**()
        FOR j FROM 1 TO 8 DO
            FOR i FROM 1 TO 5 DO
            movej Homepoint,v1000,z0,Alip\WObj:=PoytaO;
            Movej offs (Pick,PickColumn{i},PickRow{j},30),v1000,z0,Alip\WObj:=PoytaO;
            Movej offs (Pick,PickColumn{i},PickRow{j},5),v100,z0,Alip\WObj:=PoytaO;
            g_VacuumOn1;
            Movej offs (Pick,PickColumn{i},PickRow{j},0),v10,z0,Alip\WObj:=PoytaO;
            Movej offs (Pick,PickColumn{i},PickRow{j},10),v10,z0,Alip\WObj:=PoytaO;
            Movej offs (Pick,PickColumn{i},PickRow{j},20),v1000,z0,Alip\WObj:=PoytaO;
            movej Homepoint,v1000,z0,Alip\WObj:=PoytaO;
            DropPart;
            ENDFOR
        ENDFOR
       ENDPROC
    
    PROC **DropPart**()
        FOR x FROM 1 TO 4 DO 
            FOR y FROM 1 TO 10 DO
            Movej offs (Drop,DropColumn{x},DropRow{y},50),v1000,z0,Alip\WObj:=PoytaO;
            Movej offs (Drop,DropColumn{x},DropRow{y},10),v100,z0,Alip\WObj:=PoytaO;
            Movej offs (Drop,DropColumn{x},DropRow{y},0),v10,z0,Alip\WObj:=PoytaO;
            g_VacuumOff1;
            Movej offs (Drop,DropColumn{x},DropRow{y},10),v10,z0,Alip\WObj:=PoytaO;
            Movej offs (Drop,DropColumn{x},DropRow{y},50),v1000,z0,Alip\WObj:=PoytaO;
            **RETURN**;
            ENDFOR
        ENDFOR
       ENDPROC

The way your code works without the return is that it will pick one part, then drop part 40 times in a row.
Is this your desired function?

There is no problem with nesting multiple for loops in rapid.