I have a different conundrum related to switch cases that the order in which the cases are mentioned. The following code does not compile
This is the newjob rule:
say "[description of sponsor_expansion][paragraph break]";
if status of job posting is:
-- completed: say "You have already completed that mission.";
-- latent: say "What job?"; [this mission should not have been revealed yet]
-- denied: say "You have already denied that mission.";
-- accepted: say "You have already accepted that mission.";
-- offered:
if player has the job posting:
follow the jobOffer rule;
otherwise: [need the posting to proceed]
say "[description of get_job_posting]";
Problem. You wrote âofferedâ but this seems to be misplaced since it is not a case within an âif X isâŚâ, as it must be. Each case must be placed one tab stop in from the âif X isâŚâ to which it belongs, and the instructions for what to do in that case should be one tab stop further in still.
The enigma comes from this code which does compile.
This is the newjob rule:
say "[description of sponsor_expansion][paragraph break]";
if status of job posting is:
-- offered:
if player has the job posting:
follow the jobOffer rule;
otherwise: [need the posting to proceed]
say "[description of get_job_posting]";
-- completed: say "You have already completed that mission.";
-- latent: say "What job?"; [this mission should not have been revealed yet]
-- denied: say "You have already denied that mission.";
-- accepted: say "You have already accepted that mission.";
Anyone shed some light on this puzzle? I have moved lines around, retyped them, etc. The one that works is a simple cut-n-paste (not a retyping) of the non-working code.
The documentation at WI 11.8 Otherwise suggests, but does not specifically say, you canât mix inline and block conditions. The documentation gives two examples, one in which all conditions are blocks, and one in which all conditions are inline. Chances are Inform will accept a mixture of blocks and inlines if the first condition is a block. I personally always write switches in block form.
Four of the conditions are âinline,â meaning the condition and what the game should do about it are on the same line. The condition you moved is a block involving more than one line of code. Why it worked with the block first, and not with the block last, could be a result of how the compiler interprets the code. Or, it could be a bug. As I said, the documentation suggests you shouldnât mix them, but it doesnât explicitly say you canât mix them.
Okay. Unaware of your comment, I revised the code to clean it up and have this (working) code now:
This is the newjob rule:
say "[description of sponsor_expansion][paragraph break]";
if status of job posting is:
-- latent: follow the jobOffer rule;
-- offered: follow the jobOffer rule;
-- accepted: say "You have already accepted that mission.";
-- denied: say "You have already denied that mission.";
-- completed: say "You have already completed that mission.";
I had to think about what you said. I did have mixed structure. My if statement within a â-- caseâ confused the compiler and it threw an error on the last case in the list before the iffâing started, which is why changing the sequences of cases around changed the flagged word but not the compilation. Good to know.