01-18-2017
02:01 AM
- last edited on
10-23-2024
11:51 AM
by
Content Cleaner
Hi, just upgraded to TestStand 2016f1 today.
So I created a typdef Enum in LabVIEW. The enum had mutlple words with spaces for a value.
I then called the VI from the teststand adpator and clicked the Create/Update Custom Date Type from Enum button.
All good so far. But now I want to use the enum in the expression.
Locals.myEnumVal==Enums.myEnumName.firstword secondword
I get an unexpected token syntax error on secondword.
If I look at http://www.ni.com/white-paper/52330/en/#toc3 I note it has quotes in the value column, where my enum has a value of
[firstword secondword] (0)
where (0) is the enum constant.
How is this supposed to work? I can't find an example. Help doesn't cover spaces. I.e no examples for a color "light blue". E.g.
locals.myFavoriteColor==Enums.Color.Light Blue
- how do we get this to work?... I assume its something obvious I have overlooked.
https://www.ni.com/docs/en-US/bundle/teststand/page/enumerations-in-teststand-expressions.html
Cheers.
Solved! Go to Solution.
01-18-2017 07:54 AM
Try the Enum() expession function - it's mentinoed in the help topic you linked.
Hope this helps!
Trent
01-18-2017 02:31 PM
Hi Trent
thanks for your reply. I found that and still couldn't figure out what it wanted or how to make it work.
Locals.myFavoriteColor==Enum(Enum.Color,Enums.Color.light blue) still gives an unexpected token.
Locals.myFavoriteColor==Enum(Enum.Color,"Enums.Color.light blue") - could not find type ".
To me the whole point of the enum is to be able to type Enums. {Prompt for defined enum names...} . {prompt for value string}
So for the color example how to get it to work?
01-18-2017 04:38 PM
Pictures...
01-18-2017 05:23 PM - edited 01-18-2017 05:32 PM
The Enum() method is expecting a string for the first input as well, try:
Locals.myFavoriteColor=Enum("Color","light blue")
or
Locals.myFavoriteColor=Enum("Color",3)
I understand what you mean about the auto complete issue, and there is actually already a CAR (612847) in place improve the auto complete usability for enums.
Hope this helps!
Trent
01-18-2017 06:18 PM
Thanks a lot for your help Trent, at least I can progress now....
I tried Locals.myFavoriteColor == Enum(Enums.Color,"Dark Blue") Error is expected type String Found type (Enum) Color.
Locals.myFavoriteColor == Enum("Enums.Color","Dark Blue") also fails as cannot find type Enums.Color.....
Lets say its not that intutive and misses the point of autocomplete alltogether. Autocomplete is currently miss-leading users down the wrong path as well. I look forward to the CAR being completed.
09-20-2017 03:21 PM - edited 09-20-2017 03:24 PM
Hello Nick,
I know you probably found an answer by now, but I wanted to give an answer in case someone else runs across this. We have a similar situation.
I believe the code needed is
Locals.myFavoriteColor = Enum("Color","Dark Blue")
I apologize. I see you did get the answer earlier.
08-23-2019 07:28 AM - edited 08-23-2019 07:31 AM
Hello,
I am using TS2017 and the same problem occurs.
Is there new workaround avaliable?
There is moe scenarios with this breaks, for example when typing
Enums.MyEnum.%s%d