06-10-2010 03:00 PM
I am attempting to create a sequence file through the TestStand API. The sequence steps consist of Statements containing Expressions. I can create the Statement steps, but need to create the variables contained within the statement.
1. Is there a way for TestStand to automatically create variables within an expression?
2. Is there a way for TestStand to detect the type of variable that should be created?
Thanks!
06-10-2010 09:30 PM
06-11-2010 01:54 PM
Allen,
Thanks for the reply.
1. Is there a way for TestStand to automatically create variables within an expression?
It seems the SetValNumber function could be used to "declare" variables using expressions during runtime/dynamically. Is it possible for this "automatically" (without additional expression lines) to occur?
2. Is there a way for TestStand to detect the type of variable that should be created?
I am trying to determine the best way of extracting variables (and expected types) from an expression. I am currently using a LabVIEW VI that searches for "Locals.","FileGlobals.", or "StationGlobals." and also validating the expression using the Expression.Validate method, but is there a way for TestStand to return the expected type of a variable? Then the proper SetValString, SetValNumber, SetValBoolean, ... could be called.
06-11-2010 02:15 PM
I'm not sure what you mean by automatically. There is no way to do this without using the API. You'll have to have a step that creates the variable if it does not exist, or call the API from a code module or expression to set the value.
Each variable has a type associated with it, so you can use the PropertyObject.Type property on each of the variables.
If I have misunderstood something about what you are trying to do, let me know.
06-11-2010 02:36 PM
I am developing an application that will convert a text file of expressions into a TestStand sequence file using the API. My goal is to extract and create required variables from expressions written in the text file. I can currently identify variables, but need to determine the variable type for each expression.
My question to "automatically create" is derived from the EvalOption_CreateNonExistentVariables option of the Evaluate method (see below)
Evaluate Method
Expression.Evaluate ( evaluationContext, evaluationOptions = EvalOption_NoOptions)
Returns the result of the expression in the form of a PropertyObject. The PropertyObject can contain a value of any type depending on the expression. Release the result when you finish using it. If the expression is empty and you pass EvalOption_AllowEmptyExpression, this method returns a NULL dispatch pointer or object reference.
Evaluates an expression and returns the result.
evaluationContext As PropertyObject
[In] Pass the context in which to evaluate the expression. This method uses this object to locate variables the expression specifies.
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.
This parameter has a default value of EvalOption_NoOptions.
EvaluationOptions
These constants represent the options you can use with the evaluationOptions parameter of the PropertyObject.EvaluateEx, Expression.Evaluate, Expression.Validate, ExpressionEdit.Evaluate, and Engine.CheckExpression methods. Use the bitwise-OR operator to specify more than one option.
06-11-2010 03:47 PM
That option will only create them during the evaluation so that any variables that don't exist won't cause an error. The type information will have to be stored somehow within the text file, as there would be no way to know what type of variable to create.