01-12-2010 06:40 AM
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);
01-12-2010 08:34 AM - edited 01-12-2010 08:38 AM
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
01-12-2010 08:38 AM
01-12-2010 08:46 AM - edited 01-12-2010 08:48 AM
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
01-12-2010 08:50 AM
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.
01-12-2010 08:55 AM
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);
01-12-2010 08:56 AM
01-12-2010 09:57 AM
01-12-2010 10:53 AM
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?
01-12-2010 03:41 PM
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