You are on page 1of 4

# Inform

•• Expressions and Operators •••••••••••• •• Constants ••••••••••••••••••••••••
Use parentheses (...) to control the order of evaluation. Named word values, unchanging at run-time, which are by
Arithmetic/logical expressions support these operators: default initialised to zero:
in four minutes Constant constant ;
A quick reference to the Constant constant = expr ;
p – q subtraction
Inform programming language Standard constants are true (1), false (0) and nothing (0),
p * q multiplication
p / q integer division
http://www.gnelson.demon.co.uk/
p % q remainder To define a constant (unless it already exists):
This guide is copyright © 2002 by Roger Firth Default constant expr ;
http://www.firthworks.com/roger/ p++ increments p , evaluates to original value
++p increments p , evaluates to new value
Version 1.3 (March 2002)
p–– decrements p , evaluates to original value •• Variables and Arrays ••••••••••••••••
––p decrements p , evaluates to new value Named word/byte values which can change at run-time and
The road to brevity is via imprecision and through solecism p & q bitwise AND are by default initialised to zero.
– refer to the Inform Designer’s Manual for the definitive story. p | q bitwise OR A global variable is a single word:
~p bitwise NOT (inversion) Global variable ;
•• Literals ••••••••••••••••••••••••••• Global variable = expr ;
A Z-code word literal uses sixteen bits (whereas a Glulx Conditional expressions return true (1) or false (0);
q may be a list of alternatives q1 or q2 or ... qN : A word array is a set of global words accessed using
word has thirty-two bits). A byte literal is always eight bits.
array-->0, array-->1, ... array-->(N–1):
• Decimal: -32768 to 32767 p == q p is equal to q
Array array ––> N ;
Hexadecimal: \$0 to \$FFFF p ~= q p isn’t equal to q
Array array ––> expr1 expr2 ... exprN ;
Binary: \$\$0 to \$\$1111111111111111 p > q p is greater than q Array array ––> "string ";
• Action: ##Look p < q p is less than q
A table array is a set of global words accessed using
• Character: 'a' p >= q p is greater than or equal to q array-->1, array-->2, ... array-->N, with array-->0
• Dictionary word: 'aardvark' (up to nine characters p <= q p is less than or equal to q initialised to N:
significant); use circumflex “^” to denote apostrophe. p ofclass q object p is of class q Array array table N ;
Plural word: 'aardvarks//p' p in q object p is a child of object q Array array table expr1 expr2 ... exprN ;
Single-character word: "a" (name property only) or 'a//' p notin q object p isn’t a child of object q Array array table "string ";
• String: "aardvark's adventure" (maximum around p provides q object p provides property q A byte array is a set of global bytes accessed using
4000 characters); can include special values including: p has q object p has attribute q array->0, array->1, ... array->(N–1):
^ newline p hasnt q object p hasn’t attribute q Array array –> N ;
~ quotes “ " ” Array array –> expr1 expr2 ... exprN ;
Boolean expressions return true (1) or false (0): Array array –> "string ";
@@64 at sign “@”
@@92 backslash “\” p && q both p and q are true (non-zero) A string array is a set of global bytes accessed using
p || q either p or q is true (non-zero) array->1, array->2, ... array->N, with array->0
@@94 circumflex “^”
~~p p is false (zero) initialised to N:
@@126 tilde “~”
@`a a with a grave accent “à”, et al To return –1, 0 or 1 based on unsigned comparison: Array array string N ;
@LL pound sign “£”, et al Array array string expr1 expr2 ... exprN ;
UnsignedCompare(p,q ) Array array string "string ";
@00 ... @31 low string 0..31
To return true if object q is a child or grand-child or... of p : In all these cases, the characters of the initialising string are
•• Names ••••••••••••••••••••••••••• IndirectlyContains(p,q ) unpacked to the individual word/byte elements of the array.
The identifier of an Inform constant, variable, array, To return a random number 1..N , or one from a list of See also Objects (for property variables) and Routines (for
class, object, property, attribute, routine or label. constant values: local variables).
Up to 32 characters: alphabetic (case not significant), random(N )
numeric and underscore, with the first character not a digit. random(value,value, ... value )
1 1

has and with (and also the rarely-used private) segments are all optional. and variable = expr . class To return the number of child objects directly below an local_var local_var . To define a dummy standalone routine with N local variables object.. statement . . •• Classes and Objects ••••••••••••••••• •• Manipulating the object tree •••••••••• •• Routines ••••••••••••••••••••••••• To declare a class – a template for a family of objects – To change object relationships at run-time: A routine can have up to 15 local variables: word values where the optional (N ) limits instances created at run-time: move object to parent_object .print_to_array(array ) final “]” or an explicit return statement: property return expr . = expr . a7 ) child(object ) To declare an object. The class.. .create() Routine.call(a1.. a7 ). Each statement is terminated by a semi-colon “.. addressed by object.. To return the adjacent child of an object’s parent (or whose values initialise the equivalent local variables remaining four header items are all optional. property value •• Statements •••••••••••••••••••••••• property value value . class To return the parent of an object (or nothing): A standalone routine: has attr_def attr_def .&property-->0. in this case An exclamation “!” starts a comment – rest of line ignored. A property variable is addressed by object. indirect(routine. “Object” can instead be a class.) and parent_object are incompatible: • returns true at the final “]” sibling(object ) [ routine Object arrows object "ext_name " parent_object class class class ..print() Routines return a single value. String (or nothing): can also be called explicitly using object.. which are private to the routine and which by default are set Class class(N ) remove object . the • can take arguments..a2.. object... with/private segments: Each prop_def declares a variable To a string: ] (or word array) and can take any of these forms (where a string. a7 ) statement .property() class. original value prior to any changes within the object. and is called when the property is invoked. with prop_def .&property-->1.. . variable = expr... 2 2 .. statement .. ... when execution reaches the value is an expression. value return... -> ->.class::property . Object. To return the first child of an object (or nothing): also be called indirectly using prop_def . Multiple values create a property array.}. by which it is called using routine().remaining() • has no name.property(a1.. rtrue.property ) ..a2.”..from_object ) • returns false at the final “]” has segment: Each attr_def is either of: To an object: property [ attribute local_var local_var . a string or an embedded routine): string. .a2..#property is the number of bytes occupied by the (unless it already exists): A common statement is the assignment: array. To change attributes at run-time: To a routine: statement .. Recursion is permitted. parent(object ) • has a name. prop_def . using routine(a1... and arrows nothing): (->.destroy(object ) metaclass(object ) class. statements enclosed in braces {. ~attribute object.recreate(object ) • accepts arguments only when called explicitly class. has attr_def attr_def .. the entries can be accessed using Stub routine N .. .. . local_var . attr_def with prop_def . and can appear in any order.. . this gives the variable = expr. class class class . class... children(object ) . give object attr_def attr_def . To a class: A routine embedded as the value of an object property: class. local_var .a2.property refers to the value of the first entry. There are two forms of multiple assignment: A property variable inherited from an object’s class is variable = variable = . routine... object. . •• Message passing •••••••••••••••••••• ].a1..copy(to_object. attr_def object: statement . To determine an object’s class as one of Class. rfalse. . to zero on each call. a7 ) .property (or A statement_block is a single statement or a series of within the object’s declaration as self... object. statement .. attr_def .. can ...

(name) object the external (short) name of the object string N string_var . statement .... “print_ret” can be statement_block omitted: To save and restore the program state: To execute statements depending on the value of expr: "string ".label ..value.. . inversion. switch (expr ) { Each value can be an expression.. ! break. . if (expr ) ... To execute statements for all objects selected by expr: objectloop (expr_starting_with_variable ) To change the font attributes: statement_block style bold. statement ..." is output as text... value . then return statement_block .. ! To jump out of the current innermost loop or switch: style reverse..value... To output the Inform compiler version number: value: statement. statement_block .. . a string or a rule. A string in quotes ". 3 3 . . optionally. . To execute statements for all defined objects: To change from regular to fixed-pitch font: objectloop (variable ) font off.. statement . An expression is output as a signed decimal value.value.. font on.. . value .. save label ... default: statement.constant. . constant. else If the first (or only) value is a string. statement_block until (expr ) To output multiple spaces: spaces expr . To execute statements while a variable changes: for (set_var : loop_while_expr : update_var ) To output text in a display box: statement_block box "string " "string " ... statement_block quit. restore label . .. . •• Flow control ••••••••••••••••••••••• •• Displaying information ••••••••••••••• •• Uncommon and deprecated statements •• To execute statements if expr is true. continue. statement . "string ". value . where each value can be given as: (char) expr the expr as a single character To assign to one of 32 ‘low string’ variables: constant (string) addr the string at the addr lo_constant to hi_constant string N "string ". A rule is one of: } To accept data from the current input stream: (number) expr the expr in words read text_array parse_array routine . value: statement.. true from the current routine: if (expr ) To terminate the program: print_ret value. to execute To output a list of values: To jump to a labelled statement: other statements if expr is false: print value. To output a list of values followed by a newline. •• Loop control ••••••••••••••••••••••• (a) object the short name preceded by “a/an” To execute statements while expr is true: (the) object the short name preceded by “the” (The) object the short name preceded by “The” while (expr ) statement_block (routine ) value the output when calling routine(value ) To execute statements until expr is true: To output a newline character: do new_line. . To immediately start the next iteration of the current loop: style roman. jump label .. ! use one or more of these style underline. constant (address) addr the dictionary word at the addr Lowstring string_var "string ".

4 4 .... Include "Grammar". then return true from End.. Useful commands include: * token token . " is too heavy for that." attribute an object with that attribute To display a compile-time message: has light. use “infrmw32” at the DOS prompt): * token token . token –> action To conditionally compile: Constant Headline "^My first Inform game. "^Hello!^". omitting those in specified object Replace routine . where instead “Verb” can be “Verb meta”. Include ">source_file ".Pushdir: noun=routine an object for which routine returns true print_ret (The) self. Include "source_file ". Take. ! * token token . ! Include "VerbLib". look them up if necessary.. inform commands source_file ... Verb 'verb ' 'verb ' . type: Switches list_of_compiler_switches . “action ” can be Iffalse expr . ].. To explicitly trigger a defined action. To modify an existing verb: Statusline score.. enable Debug tools can be omitted.. Link "compiled_file ". •• Verbs and Actions •••••••••••••••••• •• Other useful directives ••••••••••••••• •• File structure •••••••••••••••••••••• To specify a new verb: To include a directive within a routine definition [.. token –> action . token –> action .. "string ". with name 'writing' 'desk' 'table'. * token token . searching the Library path: with before [. 'verb ' insert a hash “#” as its first character.Push. Class Room Endif. = 'existing_verb '.. To add synonyms to an existing verb: Release expr . token –> action Constant MANUAL_PRONOUNS.. * token token . Serial "yymmdd ". –~S disable both Strict checks and Debug tools where instead “Extend” can be “Extend only” and “last” Property property expr .. [ Initialise. ! use any one of these .. omitting the specified object To specify that a library routine is to be replaced: Furniture "writing desk" study multiinside as multi.. multiexcept as multi. token –> action Attribute attribute .. location = study.^". <<action noun second >>. search for Included files in these directories Import variable variable . A minimal source file: Verb 'verb ' 'verb ' .". ] scope=routine an object in this re-definition of scope has static supporter. 'word ' that literal word 'w1 '/'w2 '/. Statusline time.. variable .... –s display game’s size and other statistics <action noun second >. (default is score): description "It seems old and blunt. Include "Parser". To declare a new property common to all objects: Property property .". tokens are optional and each is one of: . Iftrue expr .]. token –> action To declare a new attribute common to all objects: To compile (on a PC. or changed to “first” or “replace” –X enable Infix debugger To explicitly trigger a defined action (both noun and second •• Uncommon and deprecated directives ••• –r output all game text to file (for spell-check) are optional. To display full compiler help. Constant Story "MYGAME"..dir.Pull. Ifdef name . with description "A bare room.. inform –h –h1 –h2 System_file.... any one of those literal words .. •• Compiler ••••••••••••••••••••••••• Extend 'existing_verb ' last * token token . creature an object with animate attribute held an object held by the player Message "string ". –~SD disable Strict checks... Class Furniture noun an object in scope To include the contents of a file.... topic any text number any number To set the game’s release number (default is 1). Ifndef name . depending on the action): You’re unlikely to need these. –v8 compile in Version 8 format (default is v5) the current routine: +dir... Ifnot. –z display game’s memory map Abbreviate "string " "string " . serial Object –> –> axe "rusty axe" routine a general parsing routine number (default is today’s yymmdd ) and status line format with name 'rusty' 'blunt' 'axe' 'hatchet'. To include the contents of a file in the same location as the multiheld one or more objects held by the player current file: multi one or more objects in scope Room study "Your study". ! “action reverse”.