03-31-2010 02:23 AM
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
Solved! Go to Solution.
03-31-2010 03:20 AM
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
03-31-2010 04:17 AM
Of course, thank you! Stupid of me to overlook that.
Regards
Peter