# Variable robtarget name

**URL:** <https://tech-community.robotics.abb.com/t/variable-robtarget-name/1790>\
**Category:** Robot Controller\
**Created:** [April 9, 2008, 2:36pm UTC](https://tech-community.robotics.abb.com/t/variable-robtarget-name/1790 "2008-04-09T14:36:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kwatta](https://avatars.discourse-cdn.com/v4/letter/k/ce73a5/32.png) [@kwatta](https://tech-community.robotics.abb.com/u/kwatta)\
**Post date:** [April 9, 2008, 2:36pm UTC](https://tech-community.robotics.abb.com/t/variable-robtarget-name/1790/1 "2008-04-09T14:36:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Peter\_ABB](https://avatars.discourse-cdn.com/v4/letter/p/c67d28/32.png) [@Peter\_ABB](https://tech-community.robotics.abb.com/u/Peter_ABB)\
**Post date:** [April 16, 2008, 3:54pm UTC](https://tech-community.robotics.abb.com/t/variable-robtarget-name/1790/2 "2008-04-16T15:54:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![aNoRSWE](https://avatars.discourse-cdn.com/v4/letter/a/71e660/32.png) [@aNoRSWE](https://tech-community.robotics.abb.com/u/aNoRSWE)\
**Post date:** [June 16, 2008, 3:08pm UTC](https://tech-community.robotics.abb.com/t/variable-robtarget-name/1790/3 "2008-06-16T15:08:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Thilbi](https://avatars.discourse-cdn.com/v4/letter/t/c2a13f/32.png) [@Thilbi](https://tech-community.robotics.abb.com/u/Thilbi)\
**Post date:** [June 17, 2008, 11:21am UTC](https://tech-community.robotics.abb.com/t/variable-robtarget-name/1790/4 "2008-06-17T11:21:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![aNoRSWE](https://avatars.discourse-cdn.com/v4/letter/a/71e660/32.png) [@aNoRSWE](https://tech-community.robotics.abb.com/u/aNoRSWE)\
**Post date:** [June 18, 2008, 9:19am UTC](https://tech-community.robotics.abb.com/t/variable-robtarget-name/1790/5 "2008-06-18T09:19:36Z")

</div>

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

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