switch
Syntax
switch <examinedValue>
case <otherValue1>
<commands1>
exit switch
case <otherValue2>
<commands2>
[default
<commands3>
]
end switch
switch the name of this window
case "Home" -- we fall through here and do the same as SharedFile.
case "SharedFile"
answer "Main file!"
exit switch
case 15
answer "Some other file"
exit switch
default
answer "any other file"
end switch
Explanation
The Switch command works like the switch
command in C or Go. It compares the
examinedValue
to the values of the various case
sections (otherValue1
and
otherValue2
). If the two values match, the commands under that case are executed.
Note: If you do not write exit switch
at the end of a case, execution will
“fall through” and the commands in the next case will be executed as well, even
if the case label on it doesn’t match the examinedValue
. This is especially useful
for having several cases map to the same commands.