Integer Variables?

How do you make a simple integer variable and change it?

In another language, this might be simply:

int something = 10;

I’ve tried many things:

Something is 10.

Something is a number. It is 10.

Something is a number equal to 10.

Something is an integer…

And so on, and so on. Searching on the Inform 7 documentation doesn’t seem to be helping, as is not uncommon for me.

The target score is a number variable. The target score is 23.

Check out “4.12. Values that vary” in the manual.

The phrase “X that varies” means the same thing as “X variable” if you see that in someone’s source code.

The primitive types in Inform 7, with their C++ equivalents, are truth states (booleans), numbers (ints), text (const chars), indexed text (std::strings), objects (if created as a variable, actually an object), and subtypes of objects (things, rooms, directions…).

You can also create an enum with “Color is a kind of value. The colors are red, green, and blue.” Now you can have a color that varies, a color property, etc.

Hope this helps!

Except that texts can also be functions and other fun things! :slight_smile:

Thank you… my search fu was incredibly weak on this one or something, but I tried about 10 searches! I have no idea why searching the term “numeric variable Inform 7” or “integer variable Inform 7” didn’t bring up the right page for me. I wish there was a more proper documentation like the MSDN with links from classes to properties etc.

Anyway, even though I’ve read this before, somehow the way you wrote it all in one place and concisely there, Draconis, has helped me see some of the underlying structure of the language as a program better.

Now, what, if anything, is the difference “under the hood” between “X is a number variable” and “X is a number that varies”? I guess it’s just an academic question, but I’m still curious.

Make sure you get thoroughly acquainted with the Index - it’s one of Inform 7’s most important features.

There’s no difference at all, just a matter of taste.

Note that that’s for global variables.

Local variables, within a phrase or rule, are defined by “let X be a KIND;”, or “let X be PRIMITIVE” for certain kinds.

Also .