NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I use EvaluateEx in Visual Studio 2008 with TestStand?

I am programming a custom step type in TestStand. Currently the step type allows the user to edit the popup through a dialog box. When the user puts in something that has to be evaluated such as Locals.NumTxt++, it prints "Locals.NumTxt++". I would like it to print the actual numeric value. I am trying to use the EvaluateEx. Here is my code snippet:

 

        private static PropertyObject propertyObject; // The properties of the current sequence.
        private static PropertyObject eval;
        m_Seq = seqContext;
        propertyObject = m_Seq.AsPropertyObject();
        eval = m_Seq.AsPropertyObject();
        eval = propertyObject.EvaluateEx("Step.Config.MessageText", 0);
        // Grab the data from TestStand.
       propertyObject.SetValString("Step.Config.MessageText", 0, eval.GetValString("", 0));

       string messageText = propertyObject.GetValString("Step.Config.MessageText", 0);

 

0 Kudos
Message 1 of 10
(4,876 Views)

Hi,

 

shouldn't eval be a string as that's what you are asking for (propertyObject.EvaluateEx("Step.Config.MessageText", 0); returns the value of that property). eval is not a PropertyObject. Just checked the Reference Manual.

Also I thing your reference to your Step is wrong unless ofcourse your Step is called Step in your Sequence.

 

Regards

Ray Farmer

Message Edited by Ray Farmer on 01-12-2010 02:38 PM
Regards
Ray Farmer
0 Kudos
Message 2 of 10
(4,866 Views)
Could you explain to me what you mean? I don't completely understand. I used a separate property object because I need the original one to set the message to whatever the evaluation result is? Does that make sense?
0 Kudos
Message 3 of 10
(4,862 Views)

Hi,

 

 

You have performed a EvalulateEx on  "Step.Config.MessageText" but this contains "Locals.NumTxt++". So now the value in Locals.NumTxt has incremented.

 

But you now need to get the actual value from Locals.NumTxt and store it in Step.Config.MessageText.

 

ie       propertyObject.SetValString("Step.Config.MessageText", 0, locals.NumTxt.GetValString("", 0));

 

Regards

Ray Farmer

 

 

Message Edited by Ray Farmer on 01-12-2010 02:48 PM
Regards
Ray Farmer
0 Kudos
Message 4 of 10
(4,858 Views)

Yes that it is what I am trying to do. So I set the value of the Step.Config.MessageText to the incremented number and then I get that value and put it into the string messageText for printout. That is what I tried to do, but my way is not working. Now when I do it this way:

 

 eval = propertyObject.EvaluateEx(messageText, EvaluationOptions.EvalOption_DoNotAlterValues);
                propertyObject.SetValNumber("Step.Config.MessageText", 0, eval.GetValNumber("", 0));
                messageText = propertyObject.GetValString("Step.Config.MessageText", 0);

 

 

I get the number it is set to but not the incremented number. I also get an error because it does not come out as a string.

 

0 Kudos
Message 5 of 10
(4,854 Views)

Correction on code snippet:

 

                string messageText = propertyObject.GetValString("Step.Config.MessageText", 0);
                eval = propertyObject.EvaluateEx(messageText, EvaluationOptions.EvalOption_DoNotAlterValues);
                propertyObject.SetValString("Step.Config.MessageText", 0, eval.GetValString("", 0));
                messageText = propertyObject.GetValString("Step.Config.MessageText", 0);
               

0 Kudos
Message 6 of 10
(4,853 Views)
I cannot put locals.numtxt in the getval because it needs to work no matter what the user puts in the messagebox so if it was locals.hextxt++ it has to still be able to evaluate it.
0 Kudos
Message 7 of 10
(4,851 Views)
By definition, the result of a post increment expression is the value before the increment.  If you use a pre increment expression, you will get the final incremented value, ie. ++Locals.NumTxt
0 Kudos
Message 8 of 10
(4,842 Views)

Okay I got the number part to work using this snippet:

 

                PropertyObject eval;
                eval = propertyObject.GetPropertyObject("Step.Config.MessageText", 0);   

                eval = propertyObject.EvaluateEx(messageText, EvaluationOptions.EvalOption_DoNotAlterValues);
                propertyObject.SetValString("Step.Config.MessageText", 0, eval.GetFormattedValue("", 0, "", false, ""));
                messageText = propertyObject.GetValString("Step.Config.MessageText", 0);   
           

Now say I have ++Locals.Numtxt + "is the number I want". I would want the result to be "2 is the right number". Is EvaluateEx able to do this?

0 Kudos
Message 9 of 10
(4,838 Views)

Hi,

 

 

Your Evaluate statements should look like

 

Evaluate(Evaluate("Step.Config.MessageText"))

 

Evaluate("Step.Config.MessageText") will give you the value of "Locals.NumText++"

 

Then the out Evaluate() will evaluate the expression ie Evaluate("Locals.NumText++") which increment the value in Locals.NumText.

 

 

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 10 of 10
(4,816 Views)