Passing parameters to routine

hi…

I’m having a hard time understanding something… If anyone can clarify I would be very grateful.

I’m developing an application where I have a routine for heating the robot’s axes (PROC RobotHeating(INOUT robtarget pathsR{*}, bool isSetHeatingPositionsP).

In the application I have the following code (which gives an error) …

    PERS robtarget p1:=[[1244.93,-1188.63,726.76],[0.687838,0.00599827,0.725834,0.00287952],[-1,-1,0,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
    PERS robtarget p2:=[[31.68,-1328.93,2622.03],[0.745578,0.250734,0.210509,-0.580458],[-1,-2,1,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
    PERS robtarget p3:=[[-749.23,-100.65,659.10],[0.234719,0.917676,0.157006,-0.279511],[-2,0,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
    PERS robtarget p4:=[[-53.82,593.00,1064.94],[0.492398,-0.492584,0.507578,0.507218],[1,2,-3,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
    PERS robtarget p5:=[[1060.64,561.04,438.51],[0.0737323,0.425606,-0.792688,0.430197],[0,1,-2,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];

PROC main()
    RobotHeating [p1,p2,p3,p4,p5],TRUE;
ENDPROC

PROC RobotHeating(INOUT robtarget pathsR{*},bool isSetHeatingPositionsP)
    ... CODE
ENDPROC

4600-802640/RAPID/T_ROB1/ModuleMain(884,22): Argument error(5): The argument for INOUT parameter pathsR is not a variable or persistent reference, or it is read-only. 03/07/2023 16:54:34 General

…but not if it’s like this.

    PERS robtarget p1:=[[1244.93,-1188.63,726.76],[0.687838,0.00599827,0.725834,0.00287952],[-1,-1,0,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
    PERS robtarget p2:=[[31.68,-1328.93,2622.03],[0.745578,0.250734,0.210509,-0.580458],[-1,-2,1,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
    PERS robtarget p3:=[[-749.23,-100.65,659.10],[0.234719,0.917676,0.157006,-0.279511],[-2,0,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
    PERS robtarget p4:=[[-53.82,593.00,1064.94],[0.492398,-0.492584,0.507578,0.507218],[1,2,-3,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
    PERS robtarget p5:=[[1060.64,561.04,438.51],[0.0737323,0.425606,-0.792688,0.430197],[0,1,-2,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
    
    PERS robtarget pathsG{5};

PROC main()
    pathsG:=[p1,p2,p3,p4,p5];
    RobotHeating pathsG,TRUE;
ENDPROC

PROC RobotHeating(INOUT robtarget pathsR{*},bool isSetHeatingPositionsP)
    ... CODE
ENDPROC

Checked: 4600-802640/RAPID/T_ROB1: No errors. 03/07/2023 17:04:20 General

Does anyone know why?

thanks.

Why have you made the parameter INOUT in the first place?

Why have you made the parameter INOUT in the first place?

Good morning lemster68 …I usually use it first, but I don’t have it as a rule. I like parameters that indicate references first whenever possible.
“It gets more organized”, my opinion, but why, is there any restriction?
Thanks.

The INOUT parameter is for use when you need to modify a data object in some way and have that modifed value written to the data permanently. So, often times it is not really needed.

OK.
In this case this is the idea, I need to permanently modify values of p1, p2,… that are seen in other routines.

That’s why my question, because it can’t be done directly using the PERS attribute chain, I have to create a PERS vector, pass the attributes to it and then I can modify, as in the example and in addition to duplicate data in the program, p1,p2 … are not the same points I have in pathsG{1}, pathsG{2} …

I don’t want to keep using pathsG{1} in the movement instructions, but p1, p2 …

thanks.

Ps. I also don’t want to be resetting every time I need to…

p1:=pathsG{1}.

Have you tried writing it as a function? Also, one thing that comes to mind is to put the robtargets of interest into an array declaration.

I didn’t understand how the function would help.
In the case of putting the robtargets of interest in an array declaration, I have the problem of having to call “pathsG{1}” in my movements.

I will try to put my situation in another way, maybe it will help to understand my problem …

I have a routine where the user executes a series of movements and each movement can set this position via ModPos. At this time another part of the program uses this position to perform another task.
When declared p1, it will always be p1, in the case of the position of the vector it will be depending on what the programmer wanted to understand, so pathsG{1} can be p3 and I won’t know.

In programming languages (java, c++,…) there are parameter passes by value and/or reference. INOUT should work as a reference, so p1,p2,… should be able to be passed and changed, but apparently that doesn’t work.

Am I correct?

No, it should work. It is just something in the way you are trying to make it work. When working with arrays, often times a FOR NEXT loop is a compact way of cycling through the data.

PERS robtarget p1:=[[1244.93,-1188.63,726.76],[0.687838,0.00599827,0.725834,0.00287952],[-1,-1,0,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
PERS robtarget pathsG{1};

! I am not doing anything out of the ordinary.
PROC main()
    ! Ok ...
    pathsG{1}:=p1;
    RobotHeating pathsG,TRUE;

    !NOk ... What's the difference?
    RobotHeating [p1],TRUE;
ENDPROC

PROC RobotHeating (INOUT robtarget pathsR{*},bool isSetHeatingPositionsP)
    MoveL paths{1},v600,fine,tool0\WObj:=wobj0;
    Stop;
ENDPROC

This part, pathsR{*} means that you are passing an array parameter INOUT. The array has to be declared and the points can be assigned to p1, p2, etc.,

OK…
So it’s not what I expected…
Thank you for your collaboration.

You are welcome.