Items in an expression

I ran into something strange this week. I added an action item to one of my groups. I used the script from a screen I was already using in FPMI which has worked fine for months.

In the script, I do some math, which entails multiplying two tags together:

{Tag1}*{Tag1}

In FPMI, it works fine, but it fails in FactorySQL. I ended up adding another item to my action item group like this:

First Item (called Tag1Result):
{Tag1}

Second Item (called ReturnValue):

{Tag1Result}*{Tag1}

This works fine.

I tried multiplying two different tags, and that didn’t work either (all tags were of type INT). Since it seems inconsistent with FPMI, I just thought I’d pass it along.

To clarify: You’re multiplying {Tag1} by itself, and {Tag1} is an opc tag in the group? What happens when it doesn’t work? Do you get a group error, or just bad quality?

If you get an error, what does it say?

Regards,

Yes, they are both tags of type INT. I also tried it with two different tags, and that fails too. The same expression works fine in FPMI.

I just tried it in a new action item on my local machine using a couple of INT tags:

{Tag_1}*{Tag_2}

This is the error log:

Error executing item Item2: Specified cast is not valid.
   at FactorySQL.Items.AccessoryActionItem.Execute(EvaluationToken Token)
   at FactorySQL.Groups.FSQLGroup.EvaluateActionItems(Boolean Triggered, EvaluationToken EvalToken)
   at FactorySQL.Groups.FSQLGroup.InternalExecute(EvaluationToken EvalToken)
Specified cast is not valid.
   at FactorySQL.Items.AccessoryActionItem.Execute(EvaluationToken Token)
   at FactorySQL.Groups.FSQLGroup.EvaluateActionItems(Boolean Triggered, EvaluationToken EvalToken)
   at FactorySQL.Groups.FSQLGroup.InternalExecute(EvaluationToken EvalToken)

I just wanted to let you know that this has been fixed for 4.2.5, which will be released a bit later this week. In the mean time, you can get around it by wrapping the items in “ToInt()”.

Regards,