# variable Robtarget

**URL:** <https://tech-community.robotics.abb.com/t/variable-robtarget/10396>\
**Category:** RAPID Programming\
**Created:** [October 6, 2021, 4:02pm UTC](https://tech-community.robotics.abb.com/t/variable-robtarget/10396 "2021-10-06T16:02:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![lordsikander](https://avatars.discourse-cdn.com/v4/letter/l/e36b37/32.png) [@lordsikander](https://tech-community.robotics.abb.com/u/lordsikander)\
**Post date:** [October 6, 2021, 4:02pm UTC](https://tech-community.robotics.abb.com/t/variable-robtarget/10396/1 "2021-10-06T16:02:06Z")

</div>

Hello to all..  
i am trying this code…  
X-Coordinates := a; (From external plc)  
Y-Coordinates := b; (From external plc)  
Z-Coordinates := c; (From external plc)

VAR Robtarget delta  
delta.trans.x := a; (From variable a to robtarget trans.x)  
delta.trans.y := b; (From variable b to robtarget trans.y)  
delta.trans.z:= c;

i am getting an error. I am writing the code in Robot Pendant, and to equate the variable a,b,c with trans.x,trans.y,trans.z values of robtarget , when i use the assign function “:=” and data type Robtarget. I can select robtarget “delta” but how to write trans.x,trans.y,trans.z to move values from a,b,c to robtarget delta. if i select all and write it myself it gives error. If some guidance on how to write and use each value trans.x,trans.y,z..

---

<div class="post-metadata">

**Author:** ![lemster68](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/lemster68/32/1945_2.png) [@lemster68](https://tech-community.robotics.abb.com/u/lemster68)\
**Post date:** [October 6, 2021, 4:13pm UTC](https://tech-community.robotics.abb.com/t/variable-robtarget/10396/2 "2021-10-06T16:13:38Z")

</div>

Are a, b and c declared as num type? After selecting delta, edit, abc. Type .trans.x and such.

---

<div class="post-metadata">

**Author:** ![lordsikander](https://avatars.discourse-cdn.com/v4/letter/l/e36b37/32.png) [@lordsikander](https://tech-community.robotics.abb.com/u/lordsikander)\
**Post date:** [October 6, 2021, 4:34pm UTC](https://tech-community.robotics.abb.com/t/variable-robtarget/10396/3 "2021-10-06T16:34:06Z")

</div>

yes sir..  
a,b and c are num type. as the coordinates data from plc is moved into a,b and c.

---

<div class="post-metadata">

**Author:** ![lordsikander](https://avatars.discourse-cdn.com/v4/letter/l/e36b37/32.png) [@lordsikander](https://tech-community.robotics.abb.com/u/lordsikander)\
**Post date:** [October 6, 2021, 4:43pm UTC](https://tech-community.robotics.abb.com/t/variable-robtarget/10396/4 "2021-10-06T16:43:05Z")

</div>

i use the same method as you respectable mentioned, selected delta and edit. when write “.trans.x” etc and equate it with “a”.  
a:= delta.trans.x  
it turns the writing “trnas.x” into red colour like wrong syntax or something.

---

<div class="post-metadata">

**Author:** ![lemster68](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/lemster68/32/1945_2.png) [@lemster68](https://tech-community.robotics.abb.com/u/lemster68)\
**Post date:** [October 6, 2021, 5:12pm UTC](https://tech-community.robotics.abb.com/t/variable-robtarget/10396/5 "2021-10-06T17:12:07Z")

</div>

delta.trans.x:=a; is correct syntax. Did you make a typo?

> [@](#):
>
> it turns the writing “trnas.x” into red colour like wrong syntax or something.

notice in your reply, trnas. Make sure you don’t leave out required . where needed.

---

<div class="post-metadata">

**Author:** ![lordsikander](https://avatars.discourse-cdn.com/v4/letter/l/e36b37/32.png) [@lordsikander](https://tech-community.robotics.abb.com/u/lordsikander)\
**Post date:** [October 12, 2021, 2:02am UTC](https://tech-community.robotics.abb.com/t/variable-robtarget/10396/6 "2021-10-12T02:02:32Z")

</div>

Sorry for the late reply i was suffering from fever.  
Sir, that issue is resolved the problem was not with the “trans.x” syntax. In the motion command right after the trans.x, trans.y and trans.z values i have to use “Wobj1” from optional arguments for my job which i was missing.

---

<div class="post-metadata">

**Author:** ![lordsikander](https://avatars.discourse-cdn.com/v4/letter/l/e36b37/32.png) [@lordsikander](https://tech-community.robotics.abb.com/u/lordsikander)\
**Post date:** [October 12, 2021, 2:14am UTC](https://tech-community.robotics.abb.com/t/variable-robtarget/10396/7 "2021-10-12T02:14:50Z")

</div>

There is a query regarding programming if you kindly give it a check  
For some numeric value like “4” saved as Input sent from the external plc,

if i see the IO tab the value is shown “4” but saving the value in some variable “reg1”, and check the Program data \> “num” reg1 it is 3.999999..

Using this variable in IF command generates an error like " IF reg1 := 4 then" … it always go for the second option “IF reg1 \< 4 then”..  
i think Round() function can’t be used in IF condition..

---

<div class="post-metadata">

**Author:** ![lemster68](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/lemster68/32/1945_2.png) [@lemster68](https://tech-community.robotics.abb.com/u/lemster68)\
**Post date:** [October 12, 2021, 11:58am UTC](https://tech-community.robotics.abb.com/t/variable-robtarget/10396/8 "2021-10-12T11:58:07Z")

</div>

Round it first then.
