Selecting multiple tags in component script

Hi! i’m beginner to ignition, i just want to ask if there’s a way to select multiple tags in button’s component script. i use event handlers “mouseclicked” but i can only control 1 tag

Instead of using the ‘Set Tag Value’ tab, use the ‘Script Editor’ tab. Here you can create whatever you want. Start with the ‘Set Tag Value’ and add your first tag. Then click on ‘Script Editor’ and the code for that instruction will be displayed. Then just copy for any additional tags.

Hi sir, first thanks for replying,
this is the instructions, can you give me an example if how i’ll write if i want to add machine2/state tag
system.tag.writeBlocking([’[default]Machine/Machine1/State Tag’], [value])

The square brackets around [tagpath] and [value] create a list containing

those items, because the system.tag.writeBlocking function requires you to

specify those arguments as a list.

like this:

system.tag.writeBlocking([’[default]Machine/Machine1/State Tag’, ’[default]Machine/Machine2/State Tag’], [value, value2])

The above is more efficient as it does it in one instruction, but you could also copy the whole instruction like this:
system.tag.writeBlocking([’[default]Machine/Machine1/State Tag’], [value])
system.tag.writeBlocking([’[default]Machine/Machine2/State Tag’], [value2])

1 Like

oh it works thanks, but how do i define the value 2? when i press button it controls same value
what i mean is to control the value dynamically by using a paramater {MachineNumber} example

If you have a MachineNumber Custom Property on the Button you could use this:

tagPath='[default]Machine/Machine%d/State Tag' % (event.source.MachineNumber)
system.tag.writeBlocking([tagPath], [value])
1 Like

If you’re reading the machine number from a tag you will need something like this:

machineNumber = system.tag.readBlocking(['[default]MachineNumber'])[0].value
tagPath='[default]Machine/Machine%d/State Tag' % (machineNumber)
system.tag.writeBlocking([tagPath], [value])

You could also do this without any code by adding two Custom Properties to the button:
MachineNo - Bound to the MachineNumber tag or property
MachineState - Bound to an Indirect tag of the Machine State:

Then just use the Set Property on the button:

Hi sir thanks for all the help, ahm
machineNumber = system.tag.readBlocking([’[default]MachineNumber’]) - on this part should i put the path of my tag “machinenumber” here?

Haha i used this and paste “machineNumber” tag path then it worked.

Thank you so much sir David