08-22-2019 05:30 AM
Hello,
I want to insert into my teststand report the messages displayed to the operator (Message Popups). To do so, I use the "Step.MessageExp" value.
Sometimes this message has to be evaluated.
Example of message expression: "Please do: "+ (
(Locals.Case == "A")? "This":
(Locals.Case == "B")? "That":
(Locals.Case == "C")? "Wathever":
"Unexpected case")
And sometimes it is just a string (eg: "Please do that")
The problem I am facing is that if I use the following post-expression, it won't work when the message is just a string because nothing has to be evaluated:
Step.Result.ReportText="The following text was displayed:" + Evaluate(Step.MessageExpr)
How can I solve this?
Thank you!
08-22-2019 09:22 AM - edited 08-22-2019 09:23 AM
I can't reproduce what you are seeing, in other words, both strings and expressions work the same for me. What version of TestStand are you using? Also, do you have a simple example you could post that exhibits this behavior?
08-22-2019 10:38 AM
I am using TestStand 2019 32-bits.
I wasn't able to reproduce the problem because I changed my code in the meantime. But I am still facing the same kind of problem. I brought an example here.
I want to add the picture displayed in the MessagePopup in the report by adding the following post-expression code:
Step.Result.ReportText="The following image was displayed:
" +( (Step.FileData.ShowFile )? "<IMG ALT='"+Evaluate(Step.TitleExpr)+"' src='"+ Locals.SequenceDir + "\\"+ Evaluate(Step.FileData.Path) +"' width='500px'></IMG>":"No File Displayed" )
When Step.FileData.Path is a "Path" and not an "Expression", Evaluate(Step.FileData.Path) won't work as I get the error in my example: Error in call to expression function 'Evaluate'. Unknown variable or property name 'cat'.
Why can't Evaluate("cat.jpg") return the string "cat.jpg"?
Even changing the Evaluate(Step.FileData.Path) by :
(Step.FileData.Source==0)?Step.FileData.Path:Evaluate(Step.FileData.Path)
doesn't seems to work.
I hope my example is clear enough to highlight my problem.
08-22-2019 11:27 AM
Step.FileData.Path is a string. You do not need to evaluate. In fact you cannot evaluate it unless the string is an expression string. Hence why it is throwing an error.
There is a vast difference between a string and an expression string. If you were to type Cat.jpg into an expression in TestStand you would see the exact same error. It's because it doesn't have the quotes. For it to be an expression you need the quotes ("Cat.jpg"). Becasue Step.FileData.Path is a string then the evaluate function is evaluating Cat.jpg without quotes.
Remove the evaluate method on the path and you should be good to go.
08-23-2019 01:51 AM - edited 08-23-2019 01:53 AM
Thank you for your explanation. Is there a general expression to retrieve the path of the image in the both cases, where Step.FileData.Path is:
I tried using the Step.FileData.Source property as it seems like:
In my case I only consider cases "0" and "2", therefore I tried with :
(Step.FileData.Source==0)?Step.FileData.Path:Evaluate(Step.FileData.Path)
Even if during execution it seems to work as expected, TestStand Sequence Analyzer tells me there are errors in my code.
Here attached the sequence modified where Seq Analyzer fails
08-23-2019
12:48 PM
- last edited on
11-01-2024
12:36 PM
by
Content Cleaner
This should help eliminate the pain of the sequence analyzer.
Cheers,
08-27-2019 05:21 AM - edited 08-27-2019 05:23 AM
I am afraid it is still not working, maybe I am not using the #NoValidation properly?
The following expression returns an error in the sequence analyzer when Step.FileData.Path is a regular path (no expression). I tought that the NoValidation tag would prevent TestStand from evaluating what's Inside the expression?
((Step.FileData.Source==0)?Step.FileData.Path:#NoValidation(Evaluate(Step.FileData.Path)))
08-27-2019 01:10 PM
#NoValidation((Step.FileData.Source==0)?Step.FileData.Path:Evaluate(Step.FileData.Path))
08-28-2019 02:02 AM
This expression seems to work when all images are in the root directory of the sequence, but not when they are in a separate (relative) folder.
As in the example here enclosed.
08-28-2019 10:33 AM
It's because you have a search directory issue. You need to fix your search directories to include the folder where the files are. Or use relative paths and change your expression.