Script Vision: How to put 2 Parameters in a Tag Path

Hi, I have a basic question, I need to put two parameters inside a tag path but I don't know how code it.

I've done this with 'indirect Tag':

` [default]Folder1/tank{1}_{2}/high_level`

Where
1 and 2: Are tags of custom properties and I did'nt have any problem.

But when I trying to emulate it on a script with 2 parameters, It does not work.

First I do in on Script: get the parameter from the root container

param1 = event.source.parent.parameter1
param2 = event.source.parent.parameter2

Second: put the tagPath
tagPath = "[default]Folder1/tank%i_%i/high_level" %param1 %param2

Note: Both Parameters are integers

The error say:
TypeError: not enough arguments for format string

Is possible put more than one parameter in a script tagPath?
what would be its format?

tagPath = "[default]Folder1/tank%i_%i/high_level" % (param1, param2)

5 Likes

To clarify: This isn't an "Ignition" thing, but simply how python's "string interpolation" operator works. Multiple items must be supplied as a tuple. (Or, in certain uses, as a dictionary.)

4 Likes

See also:
https://pyformat.info/

3 Likes

Hi, I was wondering if it was possible to do the same with a binding on a text. I've tried, it doesn't seems to work, I might have missed something...
( Should I start a new topic ?)

Depends on what you're using but take a look at indirect tag bindings for either Perspective or Vision. If that's not what you need try to make your own topic and give us more info on what you're trying to do and what you've tried that failed.
Here's Vision:

And here's Perspective:

3 Likes

Allright, it's all good, I was just looking the wrong way for this problem... But stil, thank you for your help.

(I'm on perspective and I was trying to use a params in a tagPath while using "Expression" thinking that it was the go to for that situation but actually the indirect tag binding is literally for that purpose)

If you explain exactly what do you want to do, It will be easier for us help you

1 Like