In a relatively recent update to the Automation Engine, the behavior of the :SWITCH … :CASE … :OTHER … :ENDSWITCH
statements changed.
Before this change, it was possible to follow a :CASE
statement immediately with the :OTHER
statement.
After the change in behavior, this stopped working.
For example, the following script used to work fine.
:SET &ENV# = "PROD"
:SWITCH &ENV#
:CASE "DEV"
:CASE "TEST"
:CASE "PROD"
:OTHER
: PRINT "Unknown environment: &ENV#"
:ENDSWITCH
Now, however, the above script results in the message "Unknown environment: PROD".
The documentation (v21.0.9) now states:
:OTHER cannot be used on the line directly following a :CASE line. You must insert a blank line in between.
In my testing, I found that a blank line is insufficient. A comment line is also insufficient. (My tests used an SCRI object.)
To restore the expected behavior, it is now necessary to add at least one scripting statement between the :CASE
statement and the :OTHER
statement. E.g.,
:SET &ENV# = "PROD"
:SWITCH &ENV#
:CASE "DEV"
:CASE "TEST"
:CASE "PROD"
: PRINT "Environment: &ENV#"
:OTHER
: PRINT "Unknown environment: &ENV#"
:ENDSWITCH
When was this change introduced, and why?
I also noticed that the OR keyword cannot be used in :CASE
statements. E.g.,
:SET &ENV# = "TEST"
:SWITCH &ENV#
:CASE "DEV" OR "TEST" OR "PROD"
: P "Environment: &ENV#"
:OTHER
: PRINT "Unknown environment: &ENV#"
:ENDSWITCH
This will result in the message "Unknown environment: TEST". I'm almost certain it worked before. A work-around is to use :IF
instead.
:SET &ENV# = "TEST"
:IF &ENV# = "DEV" OR "TEST" OR "PROD"
: P "Environment: &ENV#"
:ELSE
: PRINT "Unknown environment: &ENV#"
:ENDIF
Was this also a change, or am I misremembering how it worked before?