I am using a Bool array to create alarms, and trying to pull from a String array of the same size to get my alarms descriptions but it seems like I cannot use the bit position to do so.
If I use {[~]String_Array_Desc[0]} as my display path, I can see the description, but if I use {[~]String_Array_Desc[{bitPosition}]}, it displays ''String_Array_Desc[0]''.
Is my syntax wrong?
Hello Julien, Unfortunately bitPosition is used when the alarm mode is set to bit State. The bitPosition is the bit you want to watch for the alarm. This allows you to trigger an alarm on a certain bit of an integer. It does not apply to arrays. Also having the reference to bit position inside the first of brackets will cause the expression to not compile. Move the [{bitPosition}] outside of the first set of brackets. So the expression would look like this.
{[~]String_Array_Desc} [ {bitPosition}]
and you will notice it will always bring back 0 index.
Hello Julien, you could try this: {[~]String_Array_Desc} [toInt(replace(split({itemPath}, "\\[")[1,0],"]",""))] If the array for the strings is too small it will display the default display path.
Hello Julien this format is the Ignition expression format. This is not python format. This script will not work in the script console. What I do when I am testing expressions is create a temp perspective window with a text area and create an expression binding on that text area. this helps when getting expressions correct as it evaluates at the bottom.
I have attached the tags that I had created and an image. expression_tags.json (1.4 KB)
Hello Julien for some reason when I pasted it is missing an \. In the expression language there needs to be \\ before the ]. In my example above there is only one \. [toInt(replace(split({itemPath}, "\\[")[1,0],"]",""))]. The markdown removes my \ character when I pasted it in. Sorry for the confusion.