I can’t seem to get the random number thing working, even if I compile the code directly out of the documentation.
When play begins:
let Y be a random number between 6 and 10;
if Y is:
-- 6: say "Six is the magic number!";
-- 7: say "The number of the day is seven!";
-- otherwise: say "Today's magic number is boring."
which I found under example 170, gives me the error:
This (also from 170):
When play begins:
let N be a random number between 1 and 5;
if N is 1:
say "N is one.";
otherwise if N is 2:
say "N is two.";
otherwise if N is 3:
say "N is three.";
say "N is more than the number of your toes."
Gets me this:
[code]The phrase or rule definition ‘When play begins’ is written using the ‘colon and indentation’ syntax for its 'if’s, 'repeat’s and 'while’s, where blocks of phrases grouped together are indented one tab step inward from the ‘if …:’ or similar phrase to which they belong. But the tabs here seem to be misaligned, and I can’t determine the structure.
The first phrase going awry in the definition seems to be ‘let N be a random number between 1 and 5’ , in case that helps.[/code]
I even tried putting these in a brand new program to make sure it wasn’t an earlier syntax error in my game.
When I try this:
Carry out Riddling:
let N be a random number between 1 and 12;
if N is 1,
say "Whats the answer to this example riddle?";
pause the game;
say "The answer.";
say "What a bout this other riddle?"
pause the game;
say "The other answer".;
which I’m guessing means I have a syntax error with the whole if/otherwise/end if business. However, a switch statement would be better anyway.
Maybe I don’t get to define the random number within the carry-out-riddling? Maybe I need to format the three statements within a choice differently? But that still doesn’t explain why the example text doesn’t work.
Jim, you were right, it was spaces instead of tabs when I copied it directly from the documentation.
I didn’t even realize there was a distinction, so it didn’t work when I retyped it either. I’ve been using spaces instead of tabs for the whole six months or so that I’ve been doing this, and haven’t run into a problem til now.
Good to know! Now I can use that switch statement which is much cleaner than a bunch of otherwises.
Updating Inform … you should be making backups of your projects on a separate physical hard drive in any case, so even in the unlikely event that the install trashes anything (it shouldn’t!), you can recover without problems. In Windows XP, for instance, the Inform app goes in Program Files, but the project files are in My Documents. Overwriting the stuff in Program Files shouldn’t affect anything in My Documents.
Compatibility issues are unlikely, but by no means impossible. The syntax checking has been tightened up a bit in the new version, for instance.
I’m pretty sure you can install the new version in a different location from the old one. I haven’t tried it, so I can’t give you tips. If I wanted to do it, I’d go into Program Files and rename the Inform 7 folder to “Inform 7 Old” before installing the new version. In the Mac, you may have to log on as an administrator to change a folder name in Applications, but it shouldn’t be hard to do. Then the new install can’t possibly overwrite the old one, and you can switch between versions if you need to simply by renaming the folders.
Plus, if you should run into compatibility issues, you can always download the old version from the Inform website and reinstall it. So there’s pretty much no way to end up trashing any of your creative work.