RobotStudio event

Variable robtarget name

Options

Hi,

Is it possible to define a variable robtarget name and use it?

Something like:

VAR STRING targetname;

VAR robtarget target1:=[[0,0,0],[...etc

VAR robtarget target2:=[[0,0,0],[...etc

VAR robtarget target100:=[[0,0,0],[...etc

VAR num x{100}:={0,0,0,0,....,0};

FOR i FROM 1 TO 100 DO

  targetname:="target"+NumToStr(i,0);

  x{i}:=targetname.trans.x+10;

ENDFOR

 

Thanks

 

 

Comments

  • Peter_ABB
    Options

    x{i}:=targetname.trans.x+10;

    in your code targetname is a string varibale, can't use targetname.trans.x

    where do u use this program?  maybe u can find other way to program.

    Peter_ABB2008-4-16 15:54:45
    Peter
  • aNoRSWE
    Options

    Sorry, that code won't be possible, late binding is only valid for procedure calls and such. You'd like something like .Net's 'FOREACH (Robtarget rt in ...)' :)

    Are you just trying to add 10mm to the x value of each target in the array? Just put all the targets in the array to begin with, and then go:

     

    VAR num x{100}:=[[0,0,0,0,....,0] ... ];

    FOR i FROM 1 TO Dim(x,1) DO

      x{i}.trans.x:=x{i}.trans.x+10;

    ENDFOR

     

  • Thilbi
    Options

    hi,

    with the option advanced rapid you can use the instruction getdataval.

    Then your programm can look so:

    VAR robtarget targetname;

    VAR robtarget target1:=[[0,0,0],[...etc

    VAR robtarget target2:=[[0,0,0],[...etc

    VAR robtarget target100:=[[0,0,0],[...etc

    VAR num x{100}:={0,0,0,0,....,0};

    FOR i FROM 1 TO 100 DO

      GetDataVal "target"+NumToStr(i,0),targetname;

      x{i}:=targetname.trans.x+10;

    ENDFOR

     

    Thilbi2008-6-17 11:21:48
  • aNoRSWE
    Options

    Thats a nice solution Thilbi, didn't think of that!

    Just a note, as of 2008, Advanced Rapid is included in the standard robotware.

     

     

    aNoRSWE2008-6-18 9:20:2