# Usage of some expression functions in the script editor of components in vision

**URL:** <https://forum.inductiveautomation.com/t/usage-of-some-expression-functions-in-the-script-editor-of-components-in-vision/100673>\
**Category:** Ignition\
**Tags:** vision, scripting\
**Created:** [January 9, 2025, 5:42pm UTC](https://forum.inductiveautomation.com/t/usage-of-some-expression-functions-in-the-script-editor-of-components-in-vision/100673 "2025-01-09T17:42:43Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Olesia\_Tutashkonko](https://avatars.discourse-cdn.com/v4/letter/o/c4cdca/32.png) [@Olesia\_Tutashkonko](https://forum.inductiveautomation.com/u/Olesia_Tutashkonko)\
**Post date:** [January 9, 2025, 5:42pm UTC](https://forum.inductiveautomation.com/t/usage-of-some-expression-functions-in-the-script-editor-of-components-in-vision/100673/1 "2025-01-09T17:42:43Z")

</div>

Good day,  
I have tried to write the scripts in Script Editor that contain next functions:

1. concat("part\_path\_A", "part\_path\_B")
2. toStr(2)

while "concat" and "toInt' has worked perfectly in expression functions, I had been disappointed that I can't use them in script editors.

This force me to write super longue code (almost 100 lines) manually by listing all possible combinations inbetween "part\_path\_A", "part\_path\_B" and also there is some number inbetween them. I shell convert this number (I can take it from memory tag or pass it as parameter to graphic object) to string before combine

Is there any way to do it (such combination of strings) by usage of other existing functions, that do works well in Script Editor of graphic component in Vision?  
Thank you very much in advance,

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [January 9, 2025, 5:50pm UTC](https://forum.inductiveautomation.com/t/usage-of-some-expression-functions-in-the-script-editor-of-components-in-vision/100673/2 "2025-01-09T17:50:47Z")

</div>

Welcome to the forum.

If you are writing a Python / Jython script then use the '`+`' operator for concatenation.  
`result = "part_path_A" + "part_path_B"`

> **[W3Schools.com](https://www.w3schools.com/python/gloss_python_string_concatenation.asp)**
>
> W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 9, 2025, 5:57pm UTC](https://forum.inductiveautomation.com/t/usage-of-some-expression-functions-in-the-script-editor-of-components-in-vision/100673/3 "2025-01-09T17:57:11Z")

</div>

Scripting in Ignition, as @Transistor mentioned, is Jython, which uses Python 2.7 syntax and has (most of) the Python 2.7 standard library available.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [January 9, 2025, 6:05pm UTC](https://forum.inductiveautomation.com/t/usage-of-some-expression-functions-in-the-script-editor-of-components-in-vision/100673/4 "2025-01-09T18:05:44Z")

</div>

> [@Olesia\_Tutashkonko](#):
>
> This force me to write super longue code (almost 100 lines) manually by listing all possible combinations inbetween "part\_path\_A", "part\_path\_B" and also there is some number inbetween them. I shell convert this number (I can take it from memory tag or pass it as parameter to graphic object) to string before combine

I'm certain that there is a better way, if you post your script, I am sure that we can help you out.

---

<div class="post-metadata">

**Author:** ![Olesia\_Tutashkonko](https://avatars.discourse-cdn.com/v4/letter/o/c4cdca/32.png) [@Olesia\_Tutashkonko](https://forum.inductiveautomation.com/u/Olesia_Tutashkonko)\
**Post date:** [January 9, 2025, 6:19pm UTC](https://forum.inductiveautomation.com/t/usage-of-some-expression-functions-in-the-script-editor-of-components-in-vision/100673/5 "2025-01-09T18:19:54Z")

</div>

> [@Transistor](#):
>
> result = "part\_path\_A" + "part\_path\_B"

Good day, Transistor, PGriffith, Irose,  
Thank your for your replies.  
It has actually helped.  
I didn't know that  
result = "part\_path\_A" + "part\_path\_B"  
would actually work.

However, if I can't use functions that do transform numbers to string, it will help me just a little bit.

I have tried "toStr", that works in expressions.  
Am I wrong with syntaxis? Is there another function?

I need to simplify this to avoid having hundreds of lines. I have different combinations of numbers after M and after Tab, that comes as parameters.

```python

if event.source.selected == 1:
MKey = system.tag.readBlocking('[Bande]MKey')[0].value	
	if (MKey==2):
		path0 = "[Bande]M2/Tab1/SomeX_LB0"
		path1 = "[Bande]M2/Tab1/SomeX_LB1"
		path2 = "[Bande]M2/Tab1/SomeX_LB2"
		path3 = "[Bande]M2/Tab1/SomeX_LB3"
		path4 = "[Bande]M2/Tab1/SomeX_LB4"
		pathR = "[Bande]M2/Tab1/SomeX_LB5"
	if (MKey==3):
		path0 = "[Bande]M3/Tab1/SomeX_LB0"
		path1 = "[Bande]M3/Tab1/SomeX_LB1"
		path2 = "[Bande]M3/Tab1/SomeX_LB2"
		path3 = "[Bande]M3/Tab1/SomeX_LB3"
		path4 = "[Bande]M3/Tab1/SomeX_LB4"
		pathR = "[Bande]M3/Tab1/SomeX_LB5"
	if (MKey==4):
		path0 = "[Bande]M4/Tab1/SomeX_LB0"
		path1 = "[Bande]M4/Tab1/SomeX_LB1"
		path2 = "[Bande]M4/Tab1/SomeX_LB2"
		path3 = "[Bande]M4/Tab1/SomeX_LB3"
		path4 = "[Bande]M4/Tab1/SomeX_LB4"
		pathR = "[Bande]M4/Tab1/SomeX_LB5"
	if (MKey==5):
		path0 = "[Bande]M5/Tab1/SomeX_LB0"
		path1 = "[Bande]M5/Tab1/SomeX_LB1"
		path2 = "[Bande]M5/Tab1/SomeX_LB2"
		path3 = "[Bande]M5/Tab1/SomeX_LB3"
		path4 = "[Bande]M5/Tab1/SomeX_LB4"
		pathR = "[Bande]M5/Tab1/SomeX_LB5"
	if (MKey==6):
		path0 = "[Bande]M6/Tab1/SomeX_LB0"
		path1 = "[Bande]M6/Tab1/SomeX_LB1"
		path2 = "[Bande]M6/Tab1/SomeX_LB2"
		path3 = "[Bande]M6/Tab1/SomeX_LB3"
		path4 = "[Bande]M6/Tab1/SomeX_LB4"
		pathR = "[Bande]M6/Tab1/SomeX_LB5"
	if (MKey==7):
		path0 = "[Bande]M7/Tab1/SomeX_LB0"
		path1 = "[Bande]M7/Tab1/SomeX_LB1"
		path2 = "[Bande]M7/Tab1/SomeX_LB2"
		path3 = "[Bande]M7/Tab1/SomeX_LB3"
		path4 = "[Bande]M7/Tab1/SomeX_LB4"
		pathR = "[Bande]M7/Tab1/SomeX_LB5"
	if (MKey==8):
		path0 = "[Bande]M8/Tab1/SomeX_LB0"
		path1 = "[Bande]M8/Tab1/SomeX_LB1"
		path2 = "[Bande]M8/Tab1/SomeX_LB2"
		path3 = "[Bande]M8/Tab1/SomeX_LB3"
		path4 = "[Bande]M8/Tab1/SomeX_LB4"
		pathR = "[Bande]M8/Tab1/SomeX_LB5"
	if (MKey==9):

```

\*\*\*\*\* (to be continued)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 9, 2025, 6:26pm UTC](https://forum.inductiveautomation.com/t/usage-of-some-expression-functions-in-the-script-editor-of-components-in-vision/100673/6 "2025-01-09T18:26:23Z")

</div>

What you've written there could be replaced exactly with:

```python
if event.source.selected == 1:
	MKey = system.tag.readBlocking('[Bande]MKey')[0].value	
	path0, path1, path2, path3, path4, pathR = [
		"[Bande]M{}/Tab1/SomeX_LB{}".format(MKey, i)
		for i in xrange(6)
	]

```

But there's probably even better opportunities for optimization if you can post your full code.  
Citations:

> **[W3Schools.com](https://www.w3schools.com/python/python_variables_multiple.asp)**
>
> W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

> **[W3Schools.com](https://www.w3schools.com/python/python_lists_comprehension.asp)**
>
> W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

[https://pyformat.info/](https://pyformat.info/)

---

<div class="post-metadata">

**Author:** ![Olesia\_Tutashkonko](https://avatars.discourse-cdn.com/v4/letter/o/c4cdca/32.png) [@Olesia\_Tutashkonko](https://forum.inductiveautomation.com/u/Olesia_Tutashkonko)\
**Post date:** [January 9, 2025, 6:31pm UTC](https://forum.inductiveautomation.com/t/usage-of-some-expression-functions-in-the-script-editor-of-components-in-vision/100673/7 "2025-01-09T18:31:17Z")

</div>

> [@Transistor](#):
>
> Python

It is resolved.  
I have found that I should just use function "str", and I works.

I had been confused a lot because expression functions that we have to use while writing expressions are not the same as somebody should use for Script writing in graphic objects.

---

<div class="post-metadata">

**Author:** ![Olesia\_Tutashkonko](https://avatars.discourse-cdn.com/v4/letter/o/c4cdca/32.png) [@Olesia\_Tutashkonko](https://forum.inductiveautomation.com/u/Olesia_Tutashkonko)\
**Post date:** [January 9, 2025, 6:32pm UTC](https://forum.inductiveautomation.com/t/usage-of-some-expression-functions-in-the-script-editor-of-components-in-vision/100673/8 "2025-01-09T18:32:55Z")

</div>

Thanks a lot.  
I has helped.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [January 9, 2025, 6:33pm UTC](https://forum.inductiveautomation.com/t/usage-of-some-expression-functions-in-the-script-editor-of-components-in-vision/100673/9 "2025-01-09T18:33:18Z")

</div>

Scripting is a full programming language based on Python 2.7.

Expression Language is more like an Excel formula. You can't write a program with it - just an expression that returns a value. It can't write to another object.

---

<div class="post-metadata">

**Author:** ![Olesia\_Tutashkonko](https://avatars.discourse-cdn.com/v4/letter/o/c4cdca/32.png) [@Olesia\_Tutashkonko](https://forum.inductiveautomation.com/u/Olesia_Tutashkonko)\
**Post date:** [January 9, 2025, 6:56pm UTC](https://forum.inductiveautomation.com/t/usage-of-some-expression-functions-in-the-script-editor-of-components-in-vision/100673/10 "2025-01-09T18:56:19Z")

</div>

Thank you very much PGriffith,  
Small question for optimisation.  
Last one.  
If you need to do next - to read multiple variables like ....

V1 = system.tag.readBlocking(path1)[0].value  
V2 = system.tag.readBlocking(path2)[0].value  
V3 = system.tag.readBlocking(path3)[0].value  
V4 = system.tag.readBlocking(path4)[0].value  
V5 = system.tag.readBlocking(path5)[0].value

You have already made a full list of path (array of path), that you are interested in

path\_all = [path1, path2, path3, ...]

How you will write a cycle to read all variables from those paths?

---

<div class="post-metadata">

**Author:** ![ryan.perretta](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.perretta/32/75110_2.png) [@ryan.perretta](https://forum.inductiveautomation.com/u/ryan.perretta)\
**Post date:** [January 9, 2025, 7:09pm UTC](https://forum.inductiveautomation.com/t/usage-of-some-expression-functions-in-the-script-editor-of-components-in-vision/100673/11 "2025-01-09T19:09:31Z")

</div>

The `system.tag.readBlocking` function takes, as its first parameter, a list of tag paths. So you can just add all of the tag paths into a list and pass that in. The returned Qualified Values will be a parallel array in the order that you supplied the tag paths.

[system.tag.readBlocking | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-tag/system-tag-readBlocking?gad_source=1&gclid=CjwKCAiAhP67BhAVEiwA2E_9g95FaLzIylMRptk3xmKfJrTGV1WTJW6wHnN4VQwOhClWD_LLBVMvOBoCaHgQAvD_BwE#syntax)

That is why even when reading one tag value you first need to index the return value like you did.

> [@Olesia\_Tutashkonko](#):
>
> V1 = system.tag.readBlocking(path1)**[0]**.value

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 9, 2025, 7:16pm UTC](https://forum.inductiveautomation.com/t/usage-of-some-expression-functions-in-the-script-editor-of-components-in-vision/100673/12 "2025-01-09T19:16:37Z")

</div>

Just don't break the paths out with unpacking like I did in my example (to keep consistency with your script).

So, instead of:

```python
	path0, path1, path2, path3, path4, pathR = [
		"[Bande]M{}/Tab1/SomeX_LB{}".format(MKey, i)
		for i in xrange(5)
	]

```

Do something like this:

```python
paths = [
	"[Bande]M{}/Tab1/SomeX_LB{}".format(MKey, i)
	for i in xrange(6)
]
values = system.tag.readBlocking(paths)
# optionally, unpack to separate variables:
v1, v2, v3, v4, v5 = [qv.value for qv in values]

```

Note the comment from @ryan.perretta about the return value from `readBlocking` - it's a _list_ of _qualified value_ objects, so if you just care about the value attribute you need to extra it.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [January 9, 2025, 7:16pm UTC](https://forum.inductiveautomation.com/t/usage-of-some-expression-functions-in-the-script-editor-of-components-in-vision/100673/13 "2025-01-09T19:16:39Z")

</div>

> [@Olesia\_Tutashkonko](#):
>
> V1 = system.tag.readBlocking(path1)[0].value  
> V2 = system.tag.readBlocking(path2)[0].value  
> V3 = system.tag.readBlocking(path3)[0].value  
> V4 = system.tag.readBlocking(path4)[0].value  
> V5 = system.tag.readBlocking(path5)[0].value

This becomes:

```python
values = [qv.value for value in system.tag.readBlocking(['path1','path2','path3','path4','path5'])]

```

and will give you a List with all of the values in the same order you provided the paths.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [January 9, 2025, 7:21pm UTC](https://forum.inductiveautomation.com/t/usage-of-some-expression-functions-in-the-script-editor-of-components-in-vision/100673/14 "2025-01-09T19:21:18Z")

</div>

> [@paul-griffith](#):
>
> ```python
> if event.source.selected == 1:
> MKey = system.tag.readBlocking('[Bande]MKey')[0].value	
> path0, path1, path2, path3, path4, pathR = [
> "[Bande]M{}/Tab1/SomeX_LB{}".format(MKey, i)
> for i in xrange(5)
> ]
> 
> ```

Wouldn't this need to be `xrange(6)` For `LB0 ... LB5`?
