I’m new to Inform6 but having a blast. This is my first question
here.
The Inform6 standard library call the appropriate section of a
before/after/life routine by setting the global variable action
before calling the routine:
Object foo
with bar [ ;
MyAction: "MyAction";
];
[ MyActionSub ;
action = ##MyAction;
foo.bar();
];
I’m not sure if the manual explains this in so many words, but it’s one of the pillars of the language. If a routine contains a bunch of action constants as case labels (like your bar property, or any normal before/after/life property), then it’s implicitly a switch() on the action global variable. Except you leave off the ## part of the constants.
The action global is just a variable; you can change it if you like. However, you might not want to if you’re going to continue with normal action processing (e.g., after routines). If you don’t want to alter the global notion of what action is happening, you might want to rely on an explicit switch() statement and pass in an argument. There are other possibilities too.
This is good to know. I don’t actually have a need to do this right now, but I like knowing all the little bits and pieces of a language so that I can use them if needed. Thank you for both of your helpful answers.