Variable robtarget name

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

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.

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 …)’ :slight_smile:

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

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

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

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