NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Evaluating Test stand expression in LabVIEW

Hi...
I'm trying to evaluate Test stand expression in LabVIEW,
I have the expression say "Locals.a+Locals.b" in a expression type variable. I have to evaluate this expression.
I found a Method in LabVIEW 'evaluateex' using invoke node. can some one please explain how to use this method.
the method asks for the input expression and the result of the method is a Refnum. How to convert this back to
data. I tried to convert the refnum to variant then to data, But I was not sucessful...
0 Kudos
Message 1 of 6
(5,378 Views)

Hi,

If you have three locals

a = 5, b = 6 and c =0 (for example)

You then call Locals.c = PropertyObject.EvaluateEx ("Locals.a + Locals.c", 0) using the API step type, this will return the result and place it in Locals.cwhich  will contain 11.

In the Edit Automation Call dialog under the parameters for the Return Value make the value to Locals.c

First you need to get a reference to the SequenceContext as a PropertyObject, then use this as the reference for the PropertyObject.

If you use the Locals as the reference then remove the Locals from the expression string eg "a + b". The result still need to go the Locals.c.

eg Locals.c = PropertyObject.EvaluateEx ("a + c", 0)  which has Locals as the API Reference.

Hope this helps

Regards

Ray Farmer

 

Regards
Ray Farmer
0 Kudos
Message 2 of 6
(5,375 Views)
Hello Lordsathish,

the other alternative is to use "Engine.CheckExpression" method. To use it in LabVIEW please see my attached example.
ine.CheckExpression

CheckExpression Method

Syntax

Engine.CheckExpression ( evaluationContext, expressionStr, evaluationOptions, errorDescription, startErrPos, endErrPos)

Return Value

Boolean

Returns True if the expression is correct. Returns False if the expression contains a syntax error. If it returns False, check the errorDescription, startErrPos, and endErrPos parameters for more information.

Purpose

Checks the validity of the expression parameter and returns error information.

Remarks

This method is similar to CheckExprSyntax, except that it checks the validity of variables in the expression.

Parameters

evaluationContext As PropertyObject

[In] Pass the context in which to evaluate the expression. This method uses this object to determine whether variables in the expression are valid. If you pass a NULL reference, this method checks only the expression syntax.

expressionStr As String

[In] Specifies the expression to check.

evaluationOptions As long

[In] Pass 0 to specify the default behavior, or pass one or more EvaluationOptions constants. Use the bitwise-OR operator to specify multiple options.

errorDescription As String

[Out] When a syntax error exists, this parameter returns an error message describing the type of error.

startErrPos As long

[Out] When a syntax error exists, this parameter returns the index of the location in the string where the error begins.

endErrPos As long

[Out] When a syntax error exists, this parameter returns the index of the location in the string of the first character beyond the syntax error.




Message Edited by My NI on 07-29-2008 09:57 AM

Message Edited by My NI on 07-29-2008 10:00 AM
Regards
MY
0 Kudos
Message 3 of 6
(5,370 Views)

Hi...

Thanks for the Info...

I was able to evaluvate the expressions...

 

0 Kudos
Message 4 of 6
(5,352 Views)

Hi MY...

Instead of using this Sequence context as evaluvation context I'm using the sequence as property obejct reference. It works correctly while evaluvating Locals, But seems to give wrong results while evaluvating expressions with File globals. when i tried passing SequenceFile as property object to Evaluvation context  it gave wrong results for expression having Locals. Wrong results in the sense it returned a False Value(Indicating error in expression) for a correct expression.

So what should be the correct Evaluvation context to evaluvate expressions with File Globals, Locals, Parameters etc...? 

Thanks 

0 Kudos
Message 5 of 6
(5,192 Views)

Hi everyone ,

I still do not know the correct evaluvation context to check the expression.

 

 

I'm using the Engine.CheckExpression method to check the expressions. 

For the parameter Evaluvation context i'm using Sequence.AsPropertyObject.NewEditContext.AsPropertyObject as input.

This evaluvation context seem to work properly for most expressions containing FileGlobals,StationGlobals,Locals...

But I'm not sure if they will work correctly for Step properties...

 

Could anyone suggest a solution. 

0 Kudos
Message 6 of 6
(5,123 Views)