Eg:
-- to switch between a series of actions depending on the value of -- our variable switchVar. This example assumes switchVar will have a -- numeric value, but you can use other values instead set actionsList = [ 0: "zeroAction", 1: "oneAction", 2: "twoAction",] do string(getAProp(actionsList, switchVar))
Note the outer "string" call. This is because, if switchVar contains a
value that isn't one of the list's properties, getAProp returns
An analogous structure can be used to do conditional assignments. Rather
than use a bunch of separate checks:
Combine them all into a single list assignment:
For more on the uses of lists, see section 12.
if x = 1 then set y = "one"
else if x = 2 then set y = "two"
else if x = 3 then set y = "three"
else if x = 4 then set y = "four"
set y = getAProp( [ 1: "one", 2: "two", 3: "three", 4: "four" ], x )