25.17. Making and testing use options

| Chapter 25: Extensions |

| 25.17. Making and testing use options

Use options (see Chapter 2 above) manifest themselves in the I6 code generated by I7 as constants which are either defined, or not. For instance, the "use American dialect" option results in the constant DIALECT_US being defined, a constant which otherwise would not be. Some use options define the constant as a particular value, others simply define it (so that I6 gives this constant the value 0).

New use options can be created as in the following examples, which are found in the Standard Rules:

> Use American dialect translates as (- Constant DIALECT_US; -).
> Use full-length room descriptions translates as (- Constant I7_LOOKMODE = 2; -).

Most Inform users will not need to test whether a use option is currently set: after all, they will know whether or not their own game uses American dialect. But an extension does not know what use options apply in the game which is using it. An extension which needs to print a list, using its own formatting, might want to know whether "use serial comma" is set. Or it might want to speak differently in American dialect.

To test for American dialect, we should ideally not use I6 to look for the constant DIALECT_US using #ifdef: there is no guarantee that this constant will not be renamed at some point. Instead we can perform the test directly in I7:

> if the American dialect option is active, ...

and similarly for all other named use options. The adjectives "active" and "inactive" have the obvious meanings for use options. This means it's possible to describe the current options like so:

> say "We're currently using: [list of active use options].";

The result might be, say,

> We're currently using: dynamic memory allocation option [8192], maximum indexed text length option [1024], maximum things understood at once option [100], American dialect option and fast route-finding option.

This may be useful for testing purposes.

The former condition "using O", true if the option O is active, false if not, has not yet been withdrawn but is now deprecated, and may be removed in future builds, since it is redundant and less flexible; please write "if O is active" instead of "if using O".

Use options can also allow the writer to raise certain maximum values. If we write an extension which needs some I6 array, say, and therefore has some limitation - for instance a footnotes presenter which can handle at most 100 footnotes before its array space runs out - it would obviously be cleaner to allow this maximum to be raised. We can set this up like so:

> Use maximum presented footnotes of at least 100 translates as (- Constant MAX_PRESENTED_FOOTNOTES = {N}; -).

With such a definition, the number given is the default value, and the I6 source is included whether or not anybody uses the option: the default value being given if nobody does. The text "{N}" is replaced with the value. So the above definition normally results in this being defined:

> Constant MAX_PRESENTED_FOOTNOTES = 100;

but if the user writes

> Use maximum presented footnotes of at least 350.

then instead the I6 inclusion becomes:

> Constant MAX_PRESENTED_FOOTNOTES = 350;

The I6 constant MAX_PRESENTED_FOOTNOTES can then be used as the size of an array, for instance.

| Previous builds allowed: if using the/-- (use option):
This condition is now deprecated. It duplicates the effect of: if ... is active, ...

Previous | Contents | Next