RobotStudio event

Indexing RobotStudio Paths

I have used RobotStudio to develop my paths and now would like to write

a simple PROC to index through those paths.



RobotStudio created, "Path1", "Path2", "Path3", etc. I have 290 paths. And

rather than write a PROC with 290 lines of code, I would like to do

something like:



FOR X FROM 1 to 290 DO

PATH{x}

ENDFOR



But how do you identify a PROC as a VAR? Or can you? This would make

my code much shorter. And easier to read. I have several similar

scenarios like this in my program.

Comments

  • Hi,

    Use the rapid instruction CallByVar.

    Here is the description from the reference manual:


    CallByVar - Call a procedure by a variable

    CallByVar
    (Call By Variable) can be used to call procedures with specific names, e.g.
    proc_name1, proc_name2, proc_name3 ... proc_namex
    via a variable.
    Example

    reg1 := 2;


    CallByVar "proc", reg1;

    The procedure
    proc2 is called.
    Best regards,
    Anders Spaak
    ABB Robotics
  • Hello!

    I dont know if this is the best or shortest syntax to handle it but you can do something like this!

    MODULE Index
        LOCAL VAR num nPath;
     
        PROC main()
           nPath:=0;
           FOR i FROM 1 TO 290 DO
              incr nPath;
              %"Path"+NumToStr(nPath,0)%;
           ENDFOR
       ENDPROC
    ENDMODULE

    MODULE Paths
        PROC Path1()
           ! Your instructions
        ENDPROC
     
        PROC Path2()
           ! Your instructions
        ENDPROC
     
        PROC Path3()
           ! Your instructions
        ENDPROC  
      
        ! TO Path 290
    ENDMODULE

  • image Thanks! Along those same lines I have set up an array of

    "alt_stop{290}" which is used to change "stop1", "stop2", "stop3", etc. In

    using the "Offs" function I would like to use the same index format, like:



    For x FROM 1 to 290 DO

    alt_stop{x}:= Offs(stop{x}, 0, 10, 10);

    ENDFOR



    However, "stop" is a constant and therefore not indexable. There are 290

    "stop"s. RobotStudio generated "stop" so there is not much I can do with

    them.