I've read about the bug in SAC that makes it so that you have to convert your enum to a string (and how to use an if statement to decide what to set it as). But I wanted to see if I could find an alternative way that didn't involve some long if statement (imagine if your enum has 5-6 options -- good grief).
First, I decided to see what would happen if I just converted the enum value directly to a string. It didn't work exactly as I'd hoped but it did get somewhere. The end result is that as long as you know the ORDER of the diff options when you're creating your SA, then this'll work.
Each item in the enumeration takes on a numeric value beginning with 301. The first item in the list is 301, the second is 302, the third is 303 and so on.
I don't know about anyone else, but I think I'd prefer this over the if statement.
I'm attaching my test pkt file in case anyone would like to test this for themselves.
In the following screen shot, P1 (the point on the left) has it's code set to the value of TestString1 which is tied to the value of Tst1. As I change Tst1, that code changes. The same thing for P2 (the point on the right) execept the code is set to TestString2 which is tied to Tst2.
Further testing shows that P4, P5 or P6 only shows up when the proper item in the enum is selected.
EDIT: This was done in SAC 2012.
Don Ireland
Engineering Design Technician
Hmmm. Upon further tinkering, I've found that if you don't need the string for anything other than the switch, you don't even need to create the variable. In your switch statement, you can put Test1.toString().
Don Ireland
Engineering Design Technician
I just had a bit of an epiphany about this one. If the enum's name is Par2 (as it is in this example), set the switch statement to Par2.value.tostring(). Now the switch statement has the text value of the currently selected item in the enum.
See the following image. The pkt file is attached for your reference. In this test case, the enum has 9 different options. If you had to do that with if statements, that would get very compicated.
EDIT: Using this method instead of what I previously suggest above, you no longer need to worry about the ORDER of the enum items.
Don Ireland
Engineering Design Technician