NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

evaluate expression error

Solved!
Go to solution

Hi,

 

in TestStand 4.1, I am trying to copy a container from FileGlobals to StationGlobals, based on a name.

The following works, although the Expression browser says that it will cause a run-time error because"Error in call to expression function 'Evaluate'. Unexpected token: .."

Locals.Name = "Name1",

StationGlobals.TargetContainer = Evaluate("FileGlobals." + Locals.Name + ".SourceContainer")

where StationGlobals.TargetContainer and FileGlobals.Name1.SourceContainer are of the same named type.

 

I tried to use EvaluateEx() but could not find construction to make it work. What would be the syntactically correct way to do this?

 

Thanks

 

Peter

 

0 Kudos
Message 1 of 3
(4,460 Views)
Solution
Accepted by topic author pwaszkewitz

Peter,

 

the reason for the "error" during evaluation of the expression at development time is that this is a"stacked" expression.

You first set Locals.Name to a new value. I think that in your sequence Locals.Name is by default an empty string. You then use this modified value in another part of the expression.

Since there is no SequenceContext (no execution running), the value of Locals.Name is actually not modified by the first part of the expression leaving the Evaluate() to search for a property "FileGlobals..SourceContainer". Since two '.' one after another are illegal for lookup strings, the evaluation of the whole expression fails.

 

This error does not occur during runtime because the first part of the expression actually changes Locals.Name (for the SequenceContext) to be "Name1", so the second part will result in Evaluate("FileGlobals.Name1.SourceContainer").

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 2 of 3
(4,453 Views)

Of course, thank you! Stupid of me to overlook that.

 

Regards

 

Peter

 

0 Kudos
Message 3 of 3
(4,448 Views)