Parameter Binding Manipulation

I would like to get parts of PathToParentFolder in parameter binding. The path is Sensor/0/Alarm. I just need the Sensor. Is there a way to do that?

You can use an expression binding.

substring(
	"Sensor/0/Alarm",
	lastIndexOf("Sensor/0/Alarm", "/") + 1
)

This returns "Alarm".

https://docs.inductiveautomation.com/display/DOC81/substring

https://docs.inductiveautomation.com/display/DOC81/lastIndexOf

This is under UDT properties and expression binding is not an option.

There's no mention of that in your original post. Can you see how this wastes people's time?

1 Like

You could create an Expression Tag as part of your UDT and use the following Expression:

split({PathToTag},"/")[0]
1 Like

I tried using split but it won't let me reference anything past the first row.
It won't take

split({PathToTag},"/")[1]

I am trying to build a OPC Item Path based on the Tag Path.

Ignition's bracket operator for subscripts (in expression bindings) can perform the following operations:

  • someArrayProp[index]
  • someObjectProp[key]
  • someDatasetProp[column]
  • someDatasetProp[row, column]

Where index is an integer, key is a string, column is either integer or string, and row is an integer.

If you need to access any non-zero row in a dataset, you must specify both row and column.

3 Likes

I created and expression tag and created a script that parses the PathToTag and used runScript and it works like a charm.

runScript("tags.gettag",0,{PathToTag})

I cannot figure out how to get that value into OPC Item Path of the tags in the UDT that contains the expression tag. I am starting to think what I am trying to do is impossible.

It's not impossible, you just have to find a different way.
You could run this in the Script Console to do exactly what you want:

def customOPCpath(path):
	#process the full Tag path to get your OPC path
	return(opcPath)

for opcTag in system.tag.browse("/", {"recursive": True, "tagType": "AtomicTag", "valueSource":"opc"}):
	tagPath = str(opcTag["fullPath"])
	opcItemPath = customOPCpath(tagPath)
	system.tag.writeBlocking([tagPath + ".OpcItemPath"], [opcItemPath])
1 Like