# Siemens String Tag

**URL:** <https://forum.inductiveautomation.com/t/siemens-string-tag/46163>\
**Category:** Ignition\
**Created:** [April 29, 2021, 2:50pm UTC](https://forum.inductiveautomation.com/t/siemens-string-tag/46163 "2021-04-29T14:50:34Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![trusk](https://avatars.discourse-cdn.com/v4/letter/t/8491ac/32.png) [@trusk](https://forum.inductiveautomation.com/u/trusk)\
**Post date:** [April 29, 2021, 2:50pm UTC](https://forum.inductiveautomation.com/t/siemens-string-tag/46163/1 "2021-04-29T14:50:35Z")

</div>

Hello,  
I am replacing an existing iFix4.0 system with a new Ignition 8.1 platform. The existing iFix system has a text (TX) tag with address DB103.DBB 4U and the value of that tag is “Vz”.

I am trying to create a string tag in Ignition to give me the same value. I initially tried the item path [L1\_Master]DB103,STRING4.2 and I get the value of “Bu VzVzSmVz BuRmRfRfP1RfBuRfC|C|P1BuP1P6P1P6”.

With a length of 2 I would only expect 2 characters. However, when I change the length to 1 there is no change in the value. Anyone run into this issue? Thanks

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 29, 2021, 3:03pm UTC](https://forum.inductiveautomation.com/t/siemens-string-tag/46163/2 "2021-04-29T15:03:16Z")

</div>

Our driver expects strings to be in the S7 string format, which is something like this:

```auto
[MaxLen][ActualLen][Remaining Bytes...]

```

Is the data laid out in that format or is it just a null terminated (or not) character sequence?

---

<div class="post-metadata">

**Author:** ![trusk](https://avatars.discourse-cdn.com/v4/letter/t/8491ac/32.png) [@trusk](https://forum.inductiveautomation.com/u/trusk)\
**Post date:** [April 29, 2021, 3:40pm UTC](https://forum.inductiveautomation.com/t/siemens-string-tag/46163/3 "2021-04-29T15:40:38Z")

</div>

Looking into the PLC data block it looks like the structure is actually a word with two ascii characters in hex. The value of the memory address is “567A” which translates to “Vz” in ascii. It looks like I may have to do some conversion on the value to get the text I need.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 29, 2021, 3:46pm UTC](https://forum.inductiveautomation.com/t/siemens-string-tag/46163/4 "2021-04-29T15:46:00Z")

</div>

If there aren’t a bunch of these and the length won’t vary it might be easiest to just pull in the individual bytes/characters and smash them together in an expression tag.

---

<div class="post-metadata">

**Author:** ![trusk](https://avatars.discourse-cdn.com/v4/letter/t/8491ac/32.png) [@trusk](https://forum.inductiveautomation.com/u/trusk)\
**Post date:** [April 30, 2021, 2:17pm UTC](https://forum.inductiveautomation.com/t/siemens-string-tag/46163/5 "2021-04-30T14:17:01Z")

</div>

Thanks. I have tried your suggestion. The problem I have now is the values of the individual byte tags are coming in as decimal (ie. 86 and 122). There is no way to convert these values from decimal to ascii text that I can find using an Ignition expression. I’m assuming I need to use a python script at this point. Any suggestions?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 30, 2021, 2:28pm UTC](https://forum.inductiveautomation.com/t/siemens-string-tag/46163/6 "2021-04-30T14:28:57Z")

</div>

Hmm, I feel like I’ve come to the conclusion that we really need some new expressions more than once now: [Read byte to ascii characters - #10 by Kevin.Herron](http://forum.inductiveautomation.com/t/read-byte-to-ascii-characters/23370/10)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 30, 2021, 2:32pm UTC](https://forum.inductiveautomation.com/t/siemens-string-tag/46163/7 "2021-04-30T14:32:52Z")

</div>

FWIW something like this also works:

```auto
runScript("chr("+{[~]C1}+")") + runScript("chr("+{[~]C2}+")") 

```

where C1 and C2 are tags holding the decimal characters.

---

<div class="post-metadata">

**Author:** ![trusk](https://avatars.discourse-cdn.com/v4/letter/t/8491ac/32.png) [@trusk](https://forum.inductiveautomation.com/u/trusk)\
**Post date:** [April 30, 2021, 3:37pm UTC](https://forum.inductiveautomation.com/t/siemens-string-tag/46163/8 "2021-04-30T15:37:36Z")

</div>

Works great! I tried to create my own script and was just going to call the script for each character in an expression tag. The script looks like this

def myfunc(decVal):  
valHex = hex(decVal)[2:]  
valText = (valHex).decode(‘hex’)  
return valText

Then the plan was to use runscript() for each character.

I like your way better. Since I’m dealing with UDTs and parameters it’s a bit cleaner. Runs great and looks like this

runScript(“chr(”+tag("[default]Line “+{Line}+”/Master/MasterTags/Mission/R"+{RNum}+"/TipodData1")+")") + runScript(“chr(”+tag("[default]Line “+{Line}+”/Master/MasterTags/Mission/R"+{RNum}+"/TipodData2")+")")

---

<div class="post-metadata">

**Author:** ![trusk](https://avatars.discourse-cdn.com/v4/letter/t/8491ac/32.png) [@trusk](https://forum.inductiveautomation.com/u/trusk)\
**Post date:** [April 30, 2021, 3:42pm UTC](https://forum.inductiveautomation.com/t/siemens-string-tag/46163/9 "2021-04-30T15:42:28Z")

</div>

Also, I agree it would be nice to have a couple of extra expression functions to handle the conversion. Thanks for the help!

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [June 7, 2021, 6:34pm UTC](https://forum.inductiveautomation.com/t/siemens-string-tag/46163/10 "2021-06-07T18:34:05Z")

</div>

You’ll find the new expression functions in the nightlies now and in 8.1.8 when it comes out.
