# ADS in - Change Var.Name

**URL:** https://discourse.nodered.org/t/ads-in-change-var-name/27210
**Category:** General
**Created:** [24 May 2020 18:44 UTC](https://discourse.nodered.org/t/ads-in-change-var-name/27210 "2020-05-24T18:44:51Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![good\_mike](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@good\_mike](https://discourse.nodered.org/u/good_mike)
#### Post date: [24 May 2020 18:44 UTC](https://discourse.nodered.org/t/ads-in-change-var-name/27210/1 "2020-05-24T18:44:51Z")

</div>

Hello,

I like to change the variable name during run mode.  
If I understand the documentation right, there is a possibility

Quote of the documentation:

"There is an possible to override the node configuration. You can add an property config to the message object. Not all configuration properties need to be overridden.

\*\*\* `config.varName` : (string) override the variable name\*\*

- `config.varType` : (string) override the variable type
- `config.varSize` : (integer) the length on RAW and STRING type
- `config.timezone` : (string) only on date and time type 'TO\_LOCAL' or 'UNCHANGED'
- `config.inProperty` : (string) the property for the outvalue
- `config.useInputMsg` : (bool) the input message will be used to build the out message or an new message will be build.
- `config.topic` : (string) the topic being checked against the message topic. It can be '' to delete an topic."

So far I have this - but it is not working (the variable name is not changing):

```auto
[{"id":"35c5b282.47cf2e","type":"tab","label":"Übungen","disabled":false,"info":""},{"id":"2d687142.4e1c6e","type":"debug","z":"35c5b282.47cf2e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":890,"y":140,"wires":[]},{"id":"56f546c8.125f18","type":"ADS In","z":"35c5b282.47cf2e","name":"","datasource":"d6fbcc42.bcca8","varName":".RolloFunktionStatus_NodeRed[1]","varTyp":"INT","inValue":"payload","varSize":"","useInputMsg":false,"timezone":"UNCHANGED","topic":"","x":640,"y":140,"wires":[["2d687142.4e1c6e"]]},{"id":"beeedd8b.28c0c","type":"inject","z":"35c5b282.47cf2e","name":"","topic":"","payload":"config.varName:(.RolloFunktionStatus_NodeRed[3])","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":400,"y":140,"wires":[["56f546c8.125f18","8dc752cc.2bb3f"]]},{"id":"8dc752cc.2bb3f","type":"debug","z":"35c5b282.47cf2e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":590,"y":220,"wires":[]},{"id":"d6fbcc42.bcca8","type":"ads-connection","z":"","host":"192.168.178.11","amsNetIdTarget":"5.36.137.117.1.1","amsNetIdSource":"192.168.178.47.1.1","port":"48898","amsPortSource":"32905","amsPortTarget":"801","adsTimeout":"500"}]

```

What is the syntax to program this.  
Please a EASY answer, best with a example - I'm a complete newbie!!

Thanks in advance for your support!!

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [24 May 2020 19:30 UTC](https://discourse.nodered.org/t/ads-in-change-var-name/27210/2 "2020-05-24T19:30:37Z")

</div>

What node type are you using? node-red-contrib-something probably.

---

<div class="post-metadata">

### Author: ![good\_mike](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@good\_mike](https://discourse.nodered.org/u/good_mike)
#### Post date: [25 May 2020 06:41 UTC](https://discourse.nodered.org/t/ads-in-change-var-name/27210/3 "2020-05-25T06:41:31Z")

</div>

Hello,

I use the node "ADS In" from "node-red-contrib-ads 1.1.22" which is running on a Raspberry PI 3B.  
The ADS-communication path is between node red on the PI and a Beckhoff CX9020 Controller which is running under Twincat 2.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [25 May 2020 08:59 UTC](https://discourse.nodered.org/t/ads-in-change-var-name/27210/4 "2020-05-25T08:59:13Z")

</div>

You are feeding the string "config.varName:(.RolloFunktionStatus\_NodeRed[3])" into the node. What you need to do is to feed the variable name, as a string, into the node by putting it in `msg.config.varname`. You can do that with a Change node.  
Have a look at the node red doc page Working with Messages, that explains about messages and how to handle data within them.

---

<div class="post-metadata">

### Author: ![good\_mike](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@good\_mike](https://discourse.nodered.org/u/good_mike)
#### Post date: [25 May 2020 19:53 UTC](https://discourse.nodered.org/t/ads-in-change-var-name/27210/5 "2020-05-25T19:53:45Z")

</div>

Hello,

thanks for the input!  
I read the mentioned document and watched the videos.  
Than I try this:

```auto
[{"id":"35c5b282.47cf2e","type":"tab","label":"Übungen","disabled":false,"info":""},{"id":"2d687142.4e1c6e","type":"debug","z":"35c5b282.47cf2e","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":1160,"y":220,"wires":[]},{"id":"56f546c8.125f18","type":"ADS In","z":"35c5b282.47cf2e","name":"","datasource":"d6fbcc42.bcca8","varName":".RolloFunktionStatus_NodeRed[1]","varTyp":"INT","inValue":"payload","varSize":"","useInputMsg":false,"timezone":"UNCHANGED","topic":"","x":920,"y":140,"wires":[["2d687142.4e1c6e"]]},{"id":"beeedd8b.28c0c","type":"inject","z":"35c5b282.47cf2e","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":310,"y":140,"wires":[["8dc752cc.2bb3f","3b94965f.b4e93a"]]},{"id":"8dc752cc.2bb3f","type":"debug","z":"35c5b282.47cf2e","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":480,"y":220,"wires":[]},{"id":"3b94965f.b4e93a","type":"change","z":"35c5b282.47cf2e","name":"","rules":[{"t":"set","p":"config.varname","pt":"msg","to":".RolloFunktionStatus_NodeRed[3]","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":140,"wires":[["56f546c8.125f18","b3470884.8d9118"]]},{"id":"b3470884.8d9118","type":"debug","z":"35c5b282.47cf2e","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"true","targetType":"full","x":800,"y":220,"wires":[]},{"id":"d6fbcc42.bcca8","type":"ads-connection","z":"","host":"192.168.178.11","amsNetIdTarget":"5.36.137.117.1.1","amsNetIdSource":"192.168.178.47.1.1","port":"48898","amsPortSource":"32905","amsPortTarget":"801","adsTimeout":"500"}]

```

Unfortunately without success.... 🤔

The variable name is not changing - I still pull the ...[1] content oft the array and not the ...[3].

What is my fault?

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [25 May 2020 20:34 UTC](https://discourse.nodered.org/t/ads-in-change-var-name/27210/6 "2020-05-25T20:34:50Z")

</div>

I don't know anything about the twincat PLC, but `.RolloFunktionStatus_NodeRed[3]` sounds like a very odd variable name. If you configure it via the node configuration what would you put in for the variable name to get what you want?

---

<div class="post-metadata">

### Author: ![good\_mike](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@good\_mike](https://discourse.nodered.org/u/good_mike)
#### Post date: [26 May 2020 17:43 UTC](https://discourse.nodered.org/t/ads-in-change-var-name/27210/7 "2020-05-26T17:43:39Z")

</div>

Yes, if I put in the string _.RolloFunktionStatus\_NodeRed[3]_ direct into the node config. the result is valid.  
It is variable out of a array. The number in the brackets describe the position inside the array.

Is the way I described in my last post the right way to override the given variable name?

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [26 May 2020 20:36 UTC](https://discourse.nodered.org/t/ads-in-change-var-name/27210/8 "2020-05-26T20:36:15Z")

</div>

> [@good\_mike](#):
>
> node-red-contrib-ads

Well it looks right to me, according to the readme. However, I wonder whether you have to provide the full config object rather than just one field. It might be worth trying that. Other than that, since no-one else has come to help, I guess maybe no-one here is using that node. I think the best thing may be to ask via an issue on the [node's Github page](https://github.com/PLCHome/node-red-contrib-ads).  
If you do find the solution post it back here in case others find this thread.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [27 May 2020 10:46 UTC](https://discourse.nodered.org/t/ads-in-change-var-name/27210/9 "2020-05-27T10:46:59Z")

</div>

Also, can I check that you have left the field empty in the config. Most nodes will give priority to the value in the config, though the readme does not say anything about that.

---

<div class="post-metadata">

### Author: ![good\_mike](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@good\_mike](https://discourse.nodered.org/u/good_mike)
#### Post date: [28 May 2020 20:12 UTC](https://discourse.nodered.org/t/ads-in-change-var-name/27210/10 "2020-05-28T20:12:03Z")

</div>

Unfortunately it doesn't help. I get an configuration error of the ADS-Node. If I go ahead with the config error the function is not working at all....  
I try also a other ("easier") variable name - not a array variable - also without success. I make a general fault. I think I lack that crucial piece of knowledge how to inject the new variable name.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [29 May 2020 07:50 UTC](https://discourse.nodered.org/t/ads-in-change-var-name/27210/11 "2020-05-29T07:50:28Z")

</div>

I think you will have to ask on the github page.

---

<div class="post-metadata">

### Author: ![good\_mike](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@good\_mike](https://discourse.nodered.org/u/good_mike)
#### Post date: [29 May 2020 11:16 UTC](https://discourse.nodered.org/t/ads-in-change-var-name/27210/12 "2020-05-29T11:16:14Z")

</div>

I already did this yesterday evening:

> **[PLCHome/node-red-contrib-ads](https://github.com/PLCHome/node-red-contrib-ads/issues)**
>
> Beckhoff TwinCat ADS support for Node-Red. Contribute to PLCHome/node-red-contrib-ads development by creating an account on GitHub.

I hope that is the formal right location to enter such a question /problem. For me, it was the first time I ever did that.

Nevertheless, many thanks for your help!

---

<div class="post-metadata">

### Author: ![good\_mike](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@good\_mike](https://discourse.nodered.org/u/good_mike)
#### Post date: [7 June 2020 14:23 UTC](https://discourse.nodered.org/t/ads-in-change-var-name/27210/13 "2020-06-07T14:23:27Z")

</div>

Now it works - thanks to all for your support. 🙂

```auto
[{"id":"2d687142.4e1c6e","type":"debug","z":"35c5b282.47cf2e","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":1280,"y":200,"wires":[]},{"id":"56f546c8.125f18","type":"ADS In","z":"35c5b282.47cf2e","name":"","datasource":"d6fbcc42.bcca8","varName":".RolloFunktionStatus_NodeRed[1]","varTyp":"INT","inValue":"payload","varSize":"","useInputMsg":false,"timezone":"UNCHANGED","topic":"","x":1180,"y":140,"wires":[["2d687142.4e1c6e"]]},{"id":"beeedd8b.28c0c","type":"inject","z":"35c5b282.47cf2e","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":310,"y":140,"wires":[["3b94965f.b4e93a"]]},{"id":"3b94965f.b4e93a","type":"change","z":"35c5b282.47cf2e","name":"","rules":[{"t":"set","p":"config.varName","pt":"msg","to":".RolloFunktionStatus_NodeRed[1]","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":140,"wires":[["56f546c8.125f18"]]},{"id":"4d41dd73.36dbe4","type":"inject","z":"35c5b282.47cf2e","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":310,"y":180,"wires":[["6105b1af.87914"]]},{"id":"6105b1af.87914","type":"change","z":"35c5b282.47cf2e","name":"","rules":[{"t":"set","p":"config.varName","pt":"msg","to":".RolloFunktionStatus_NodeRed[2]","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":180,"wires":[["56f546c8.125f18"]]},{"id":"4a0870cd.4e0be","type":"inject","z":"35c5b282.47cf2e","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":310,"y":220,"wires":[["3485e63f.dbdfaa"]]},{"id":"3485e63f.dbdfaa","type":"change","z":"35c5b282.47cf2e","name":"","rules":[{"t":"set","p":"config.varName","pt":"msg","to":".RolloFunktionStatus_NodeRed[3]","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":220,"wires":[["56f546c8.125f18"]]},{"id":"d6fbcc42.bcca8","type":"ads-connection","z":"","host":"192.168.178.11","amsNetIdTarget":"5.36.137.117.1.1","amsNetIdSource":"192.168.178.47.1.1","port":"48898","amsPortSource":"32905","amsPortTarget":"801","adsTimeout":"500"}]

```

my main fault was additional dot inside the change node after the msg 😂

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [21 June 2020 14:23 UTC](https://discourse.nodered.org/t/ads-in-change-var-name/27210/14 "2020-06-21T14:23:32Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
