Word and value holders
A-code texts can also contain word and value place-holders, which get
replaced dynamically at run-time by words or values specified by the
explicit qualifier. Place-holders of either kind can occur both outside
and inside text switches.
The dollar sign $ is used as a value place-holder. If an
unescaped dollar sign is encountered in a text to be displayed, and if
the text is used with an explicit qualifier, the dollar is replaced with
the numerical value of the qualifier. For example, the
PURSE.CONTAINS text defined in the last section, could be re-defined as
TEXT PURSE.CONTAINS
There [are/is/are] [no/$] coin[s//s] in the purse.
In this case, the A-code statement
say purse.contains, 13
would result in the display of
There are 13 coins in the purse.
Of course, as before, any A-code value-bearing entity (variable,
location, object...) could be used as a qualifier, instead of a
constant value.
A word place-holder is signalled by an unescaped hash sign #, and
is conceptually similar, except that a word, rather than a value, indicated
by the explicit qualifier is inserted in place of the hash sign. Just
what can be used as an explicit qualifier in this case, is a bit more complicated.
All declared vocabulary terms obviously have one (or more, if there
are synonyms) actual word associated with them. At the author's
discretion, most objects and possibly some locations will also have an
associated vocabulary word or words. In all these cases there
will be a "primary" word -- the first one declared
in the list of synonyms (if there are any synonyms). It is this primary
word that gets inserted in place of a word place-holder.
All of this is easier to understand on some practical illustrations. Take for
example the object chair1 with the associated nouns "chair"
and "seat". Should there be a text defined as
TEXT NO.KILL.THINGS
The # is not something mortal, so cannot be killed!
then the statement
say no.kill.things, chair1
would produce
The chair is not something mortal, so cannot be killed!
What makes this much more useful than may appear at the first glance, is
the fact that A-code variables may store either values or
pointers (references, to you Algol fans!) to arbitrary A-code entities.
Hence if the game code executes somewhere the statement
lda target, chair1 # Point variable TARGET at object CHAIR1
where "target" is a variable name, then a subsequent statement
say no.kill.things, target
will produce exactly the same display text as if the object
"chair1" or just the simple noun "chair" were used
as the explicit qualifier.
Word place-holders really come into their own because the
mandatory A-code variables ARG1 and ARG2 hold respectively the verb and
the noun of the player's last command. So assuming that the player said
"KILL CHAIR", then
say no.kill.things, arg2
would once again tell the player that chairs are not for killing.
However, there is a further subtlety here, when it comes to using player
command words pointed at by the ARG1 and ARG2 variables, because in this
case what is echoed as a part of the response is not
necessarily the primary word associated with the referenced object, but
the word actually used by the player (allowing for expansion of
abbreviations, typo correction and vocabulary folding -- see a separate
document on the full 3D structure of the
A-code vocabulary). So if the
player typed "KILL STO" (note the abbreviation of STOOL to
STO, assumed to be unambiguous in this example), the displayed response
would be
The stool is not something mortal, so cannot be killed!
Word place-holders can also appear both within and without text
switches, but we'll cover that somewhat later on, under the heading of
switch and holder interplay.
Back to the top of the document