1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-17 06:24:24 +03:00
inform7/docs/srules/S-pd.html

2507 lines
140 KiB
HTML
Raw Normal View History

2019-03-17 14:40:57 +02:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>S/act2</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="en-gb">
<link href="inweb.css" rel="stylesheet" rev="stylesheet" type="text/css">
</head>
<body>
<!--Weave of 'S/pd' generated by 7-->
2020-01-13 13:02:57 +02:00
<ul class="crumbs"><li><a href="../webs.html">&#9733;</a></li><li><a href="index.html">srules 6</a></li><li><b>Phrase Definitions</b></li></ul><p class="purpose">The phrases making up the Inform language, and in terms of which all other phrases and rules are defined; and the final sign-off of the Standard Rules extension, including its minimal documentation.</p>
2019-03-17 14:40:57 +02:00
2020-01-13 13:02:57 +02:00
<ul class="toc"><li><a href="#SP2">&#167;2. Say phrases</a></li><li><a href="#SP5">&#167;5. Using the list-writer</a></li><li><a href="#SP6">&#167;6. Text substitutions using the list-writer</a></li><li><a href="#SP7">&#167;7. Grouping in the list-writer</a></li><li><a href="#SP8">&#167;8. Lists written but not by the list-writer</a></li><li><a href="#SP9">&#167;9. Filtering in the list-writer</a></li><li><a href="#SP10">&#167;10. Responses</a></li><li><a href="#SP11">&#167;11. Values</a></li><li><a href="#SP18">&#167;18. Tables</a></li><li><a href="#SP20">&#167;20. Breaking down text</a></li><li><a href="#SP21">&#167;21. Matching text</a></li><li><a href="#SP23">&#167;23. Replacing text</a></li><li><a href="#SP24">&#167;24. Casing of text</a></li><li><a href="#SP25">&#167;25. Adaptive text</a></li><li><a href="#SP26">&#167;26. Lists</a></li><li><a href="#SP34">&#167;34. Using external resources</a></li><li><a href="#SP36">&#167;36. Control phrases</a></li><li><a href="#SP44">&#167;44. Actions, activities and rules</a></li><li><a href="#SP51">&#167;51. Rules</a></li><li><a href="#SP53">&#167;53. The model world</a></li><li><a href="#SP65">&#167;65. Understanding</a></li><li><a href="#SP69">&#167;69. Message support</a></li><li><a href="#SP70">&#167;70. Miscellaneous other phrases</a></li></ul><hr class="tocbar">
2019-03-17 14:40:57 +02:00
<p class="inwebparagraph"><a id="SP1"></a><b>&#167;1. </b>Our last task is to create the phrases: more or less all of them, but that
does need a little qualification. NI has no phrase definitions built in,
but it does contain assumptions about how "say ...", "repeat ...",
"let ...", "otherwise ..." and "end ..." will behave when defined: we
would not be allowed to call these something else, or redefine them in
fundamentally different ways. Apart from that, we are more or less free.
</p>
<p class="inwebparagraph">Most of these phrases are defined in terms of I6 code, using the <code class="display"><span class="extract">(-</span></code> and
<code class="display"><span class="extract">-)</span></code> notation &mdash; it would be too cumbersome to use the "... translates into
I6 as ..." verb for this, too. The fact that phrases are not so much
translated as transliterated was one source of early criticism of Inform 7.
Phrases appeared to have very simplistic definitions, with the natural
language simply being a verbose description of obviously equivalent I6 code.
However, the simplicity is misleading, because the definitions below tend
to conceal where the complexity of the translation process suddenly
increases. If the preamble includes "(c - condition)", and the definition
includes the expansion <code class="display"><span class="extract">{c}</span></code>, then the text forming c is translated in a way
much more profound than any simple substitution process could describe.
Type-checking also complicates the code produced below, since NI automatically
generates the code needed to perform run-time type checking at any point where
doubt remains as to the phrase definition which must be used.
</p>
<p class="inwebparagraph"><a id="SP2"></a><b>&#167;2. Say phrases. </b>We begin with saying phrases: the very first phrase to exist is the one
printing a single value &mdash; literal text, a number, a time, an object, or
really almost anything, since the vast majority of kinds in Inform are
sayable. There used to be separate definitions for saying text, numbers
and unicode characters here, but they were removed in June 2015 as being
redundant. Though they did no harm, they made some problem messages longer
than necessary by obliging them to cite a longer list of possible readings
of a misread phrase.
</p>
<pre class="display">
<span class="plain">Part SR5 - Phrasebook</span>
<span class="plain">Section SR5/1/1a - Saying - Time Values (for interactive fiction language element only)</span>
<span class="plain">To say (something - time) in words</span>
<span class="plain">(documented at phs_timewords):</span>
<span class="plain">(- print (PrintTimeOfDayEnglish) {something}; -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP3"></a><b>&#167;3. </b>Now some visual effects, which may or may not be rendered the way the user
2019-03-17 14:40:57 +02:00
hopes: that's partly up to the virtual machine, unfortunately.
</p>
<pre class="display">
<span class="plain">Section SR5/1/7 - Saying - Fonts and visual effects</span>
<span class="plain">To display the boxed quotation (Q - text)</span>
<span class="plain">(documented at ph_boxed):</span>
<span class="plain">(- DisplayBoxedQuotation({-box-quotation-text:Q}); -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP4"></a><b>&#167;4. </b>And now some oddball special texts which must sometimes be said.
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/1/8 - Saying - Some built-in texts</span>
<span class="plain">To say the/-- banner text</span>
<span class="plain">(documented at phs_banner):</span>
<span class="plain">(- Banner(); -).</span>
<span class="plain">To say the/-- list of extension credits</span>
<span class="plain">(documented at phs_extcredits):</span>
<span class="plain">(- ShowExtensionVersions(); -).</span>
<span class="plain">To say the/-- complete list of extension credits</span>
<span class="plain">(documented at phs_compextcredits):</span>
<span class="plain">(- ShowFullExtensionVersions(); -).</span>
<span class="plain">To say the/-- player's surroundings</span>
<span class="plain">(documented at phs_surroundings):</span>
<span class="plain">(- SL_Location(true); -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP5"></a><b>&#167;5. Using the list-writer. </b>The I7 list-writer resembles the old I6 library one, but has been reimplemented
2019-03-17 14:40:57 +02:00
in a more general way: see the template file "ListWriter.i6t". The following
is the main routine for listing:
</p>
<pre class="display">
<span class="plain">Section SR5/1/9 - Saying - Saying lists of things</span>
<span class="plain">To list the contents of (O - an object),</span>
<span class="plain">with newlines,</span>
<span class="plain">indented,</span>
<span class="plain">giving inventory information,</span>
<span class="plain">as a sentence,</span>
<span class="plain">including contents,</span>
<span class="plain">including all contents,</span>
<span class="plain">tersely,</span>
<span class="plain">giving brief inventory information,</span>
<span class="plain">using the definite article,</span>
<span class="plain">listing marked items only,</span>
<span class="plain">prefacing with is/are,</span>
<span class="plain">not listing concealed items,</span>
<span class="plain">suppressing all articles,</span>
<span class="plain">with extra indentation,</span>
<span class="plain">and/or capitalized</span>
<span class="plain">(documented at ph_listcontents):</span>
<span class="plain">(- WriteListFrom(child({O}), {phrase options}); -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP6"></a><b>&#167;6. Text substitutions using the list-writer. </b>These all look (and are) repetitive. We want to avoid passing a description
2019-03-17 14:40:57 +02:00
value to some routine, because that's tricky if the description needs to refer
to a value local to the current stack frame. (There are ways round that, but
it minimises nuisance to avoid the need.) So we mark out the set of objects
matching by giving them, and only them, the <code class="display"><span class="extract">workflag2</span></code> attribute.
</p>
<pre class="display">
<span class="plain">To say a list of (OS - description of objects)</span>
<span class="plain">(documented at phs_alistof): (-</span>
<span class="plain">objectloop({-my:1} ofclass Object)</span>
<span class="plain">if ({-matches-description:1:OS})</span>
<span class="plain">give {-my:1} workflag2;</span>
<span class="plain">else</span>
<span class="plain">give {-my:1} ~workflag2;</span>
<span class="plain">WriteListOfMarkedObjects(ENGLISH_BIT);</span>
<span class="plain">-).</span>
<span class="plain">To say A list of (OS - description of objects)</span>
<span class="plain">(documented at phs_Alistof):</span>
<span class="plain">(-</span>
<span class="plain">objectloop({-my:1} ofclass Object)</span>
<span class="plain">if ({-matches-description:1:OS})</span>
<span class="plain">give {-my:1} workflag2;</span>
<span class="plain">else</span>
<span class="plain">give {-my:1} ~workflag2;</span>
<span class="plain">TEXT_TY_Say_Capitalised((+ "[list-writer list of marked objects]" +));</span>
<span class="plain">-).</span>
<span class="plain">To say list of (OS - description of objects)</span>
<span class="plain">(documented at phs_listof): (-</span>
<span class="plain">objectloop({-my:1} ofclass Object)</span>
<span class="plain">if ({-matches-description:1:OS})</span>
<span class="plain">give {-my:1} workflag2;</span>
<span class="plain">else</span>
<span class="plain">give {-my:1} ~workflag2;</span>
<span class="plain">WriteListOfMarkedObjects(ENGLISH_BIT+NOARTICLE_BIT);</span>
<span class="plain">-).</span>
<span class="plain">To say the list of (OS - description of objects)</span>
<span class="plain">(documented at phs_thelistof): (-</span>
<span class="plain">objectloop({-my:1} ofclass Object)</span>
<span class="plain">if ({-matches-description:1:OS})</span>
<span class="plain">give {-my:1} workflag2;</span>
<span class="plain">else</span>
<span class="plain">give {-my:1} ~workflag2;</span>
<span class="plain">WriteListOfMarkedObjects(ENGLISH_BIT+DEFART_BIT);</span>
<span class="plain">-).</span>
<span class="plain">To say The list of (OS - description of objects)</span>
<span class="plain">(documented at phs_Thelistof):</span>
<span class="plain">(-</span>
<span class="plain">objectloop({-my:1} ofclass Object)</span>
<span class="plain">if ({-matches-description:1:OS})</span>
<span class="plain">give {-my:1} workflag2;</span>
<span class="plain">else</span>
<span class="plain">give {-my:1} ~workflag2;</span>
<span class="plain">TEXT_TY_Say_Capitalised((+ "[list-writer articled list of marked objects]" +));</span>
<span class="plain">-).</span>
<span class="plain">To say is-are a list of (OS - description of objects)</span>
<span class="plain">(documented at phs_isalistof): (-</span>
<span class="plain">objectloop({-my:1} ofclass Object)</span>
<span class="plain">if ({-matches-description:1:OS})</span>
<span class="plain">give {-my:1} workflag2;</span>
<span class="plain">else</span>
<span class="plain">give {-my:1} ~workflag2;</span>
<span class="plain">WriteListOfMarkedObjects(ENGLISH_BIT+ISARE_BIT);</span>
<span class="plain">-).</span>
<span class="plain">To say is-are list of (OS - description of objects)</span>
<span class="plain">(documented at phs_islistof): (-</span>
<span class="plain">objectloop({-my:1} ofclass Object)</span>
<span class="plain">if ({-matches-description:1:OS})</span>
<span class="plain">give {-my:1} workflag2;</span>
<span class="plain">else</span>
<span class="plain">give {-my:1} ~workflag2;</span>
<span class="plain">WriteListOfMarkedObjects(ENGLISH_BIT+ISARE_BIT+NOARTICLE_BIT);</span>
<span class="plain">-).</span>
<span class="plain">To say is-are the list of (OS - description of objects)</span>
<span class="plain">(documented at phs_isthelistof): (-</span>
<span class="plain">objectloop({-my:1} ofclass Object)</span>
<span class="plain">if ({-matches-description:1:OS})</span>
<span class="plain">give {-my:1} workflag2;</span>
<span class="plain">else</span>
<span class="plain">give {-my:1} ~workflag2;</span>
<span class="plain">WriteListOfMarkedObjects(ENGLISH_BIT+DEFART_BIT+ISARE_BIT);</span>
<span class="plain">-).</span>
<span class="plain">To say a list of (OS - description of objects) including contents</span>
<span class="plain">(documented at phs_alistofconts): (-</span>
<span class="plain">objectloop({-my:1} ofclass Object)</span>
<span class="plain">if ({-matches-description:1:OS})</span>
<span class="plain">give {-my:1} workflag2;</span>
<span class="plain">else</span>
<span class="plain">give {-my:1} ~workflag2;</span>
<span class="plain">WriteListOfMarkedObjects(ENGLISH_BIT+RECURSE_BIT+PARTINV_BIT+</span>
<span class="plain">TERSE_BIT+CONCEAL_BIT);</span>
<span class="plain">-).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP7"></a><b>&#167;7. Grouping in the list-writer. </b>See the specifications of <code class="display"><span class="extract">list_together</span></code> and <code class="display"><span class="extract">c_style</span></code> in the DM4, which are
2019-03-17 14:40:57 +02:00
still broadly accurate.
</p>
<pre class="display">
<span class="plain">Section SR5/1/10 - Saying - Group in and omit from lists</span>
<span class="plain">To group (OS - description of objects) together</span>
<span class="plain">(documented at ph_group): (-</span>
<span class="plain">objectloop({-my:1} provides list_together)</span>
<span class="plain">if ({-matches-description:1:OS})</span>
<span class="plain">BlkValueCopy({-my:1}.list_together, {-list-together:unarticled});</span>
<span class="plain">-).</span>
<span class="plain">To group (OS - description of objects) together giving articles</span>
<span class="plain">(documented at ph_groupart): (-</span>
<span class="plain">objectloop({-my:1} provides list_together)</span>
<span class="plain">if ({-matches-description:1:OS})</span>
<span class="plain">BlkValueCopy({-my:1}.list_together, {-list-together:articled});</span>
<span class="plain">-).</span>
<span class="plain">To group (OS - description of objects) together as (T - text)</span>
<span class="plain">(documented at ph_grouptext): (-</span>
<span class="plain">{-my:2} = BlkValueCreate(TEXT_TY);</span>
<span class="plain">{-my:2} = TEXT_TY_SubstitutedForm({-my:2}, {-by-reference:T});</span>
<span class="plain">objectloop({-my:1} provides list_together)</span>
<span class="plain">if ({-matches-description:1:OS})</span>
<span class="plain">BlkValueCopy({-my:1}.list_together, {-my:2});</span>
<span class="plain">BlkValueFree({-my:2});</span>
<span class="plain">-).</span>
<span class="plain">To omit contents in listing</span>
<span class="plain">(documented at ph_omit):</span>
<span class="plain">(- c_style = c_style &amp;~ (RECURSE_BIT+FULLINV_BIT+PARTINV_BIT); -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP8"></a><b>&#167;8. Lists written but not by the list-writer. </b>These are lists in the sense of the "list of" kind of value constructor, and
2019-03-17 14:40:57 +02:00
they might contain any values, not just objects. They're printed by code in
"Lists.i6t".
</p>
<pre class="display">
<span class="plain">Section SR5/1/11 - Saying - Lists of values</span>
<span class="plain">To say (L - a list of values) in brace notation</span>
<span class="plain">(documented at phs_listbraced):</span>
<span class="plain">(- LIST_OF_TY_Say({-by-reference:L}, 1); -).</span>
<span class="plain">To say (L - a list of objects) with definite articles</span>
<span class="plain">(documented at phs_listdef):</span>
<span class="plain">(- LIST_OF_TY_Say({-by-reference:L}, 2); -).</span>
<span class="plain">To say (L - a list of objects) with indefinite articles</span>
<span class="plain">(documented at phs_listindef):</span>
<span class="plain">(- LIST_OF_TY_Say({-by-reference:L}, 3); -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP9"></a><b>&#167;9. Filtering in the list-writer. </b>Something of a last resort, which is intentionally not documented.
2019-03-17 14:40:57 +02:00
It's needed by the Standard Rules to tidy up an implementation and
avoid I6, but is not an ideal trick and may be dropped in later
builds. Recursion occurs when the list-writer descends to the contents
of, or items supported by, something it lists. Here we can restrict to
just those contents, or supportees, matching a description <code class="display"><span class="extract">D</span></code>.
</p>
<pre class="display">
<span class="plain">Section SR5/1/12 - Saying - Filtering contents - Unindexed</span>
<span class="plain">To filter list recursion to (D - description of objects):</span>
<span class="plain">(- list_filter_routine = {D}; -).</span>
<span class="plain">To unfilter list recursion:</span>
<span class="plain">(- list_filter_routine = 0; -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP10"></a><b>&#167;10. Responses. </b></p>
2019-03-17 14:40:57 +02:00
<pre class="display">
<span class="plain">Section SR5/1/13 - Saying - Responses</span>
<span class="plain">To say text of (R - response)</span>
<span class="plain">(documented at phs_response):</span>
<span class="plain">carry out the issuing the response text activity with R.</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP11"></a><b>&#167;11. Values. </b>To begin with, the magic "now".
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/2/1 - Values - Making conditions true</span>
<span class="plain">To now (cn - condition)</span>
<span class="plain">(documented at ph_now):</span>
<span class="plain">(- {cn} -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP12"></a><b>&#167;12. </b>Assignment is probably the most difficult thing the type-checker has to
2019-03-17 14:40:57 +02:00
cope with, since "let" has to work when applied to both unknown names (it
creates a new variable) and existing ones (kind of value permitting). There
are also four different ways to create with "let", and two to use
existing variables. Note that the "given by" forms are not strictly
speaking assignments at all; the value placed in <code class="display"><span class="extract">t</span></code> is found by solving
the equation <code class="display"><span class="extract">Q</span></code>. This does require special typechecking, but of a
different kind to that requested by "(assignment operation)".
All of which makes the "To let" section here only slightly shorter
than John Galsworthy's Forsyte novel of the same name:
</p>
<pre class="display">
<span class="plain">Section SR5/2/2 - Values - Giving values temporary names</span>
<span class="plain">To let (t - nonexisting variable) be (u - value)</span>
<span class="plain">(assignment operation)</span>
<span class="plain">(documented at ph_let): (-</span>
<span class="plain">{-unprotect:t}</span>
<span class="plain">{-copy:t:u}</span>
<span class="plain">-).</span>
<span class="plain">To let (t - nonexisting variable) be (u - name of kind of value)</span>
<span class="plain">(assignment operation)</span>
<span class="plain">(documented at ph_letdefault): (-</span>
<span class="plain">{-unprotect:t}</span>
<span class="plain">{-initialise:t}</span>
<span class="plain">-).</span>
<span class="plain">To let (t - nonexisting variable) be (u - description of relations of values</span>
<span class="plain">of kind K to values of kind L)</span>
<span class="plain">(assignment operation)</span>
<span class="plain">(documented at ph_letrelation): (-</span>
<span class="plain">{-unprotect:t}</span>
<span class="plain">{-initialise:t}</span>
<span class="plain">{-now-matches-description:t:u};</span>
<span class="plain">-).</span>
<span class="plain">To let (t - nonexisting variable) be given by (Q - equation name)</span>
<span class="plain">(documented at ph_letequation): (-</span>
<span class="plain">{-unprotect:t}</span>
<span class="plain">{-primitive-definition:solve-equation};</span>
<span class="plain">-).</span>
<span class="plain">To let (t - existing variable) be (u - value)</span>
<span class="plain">(assignment operation)</span>
<span class="plain">(documented at ph_let): (-</span>
<span class="plain">{-copy:t:u}</span>
<span class="plain">-).</span>
<span class="plain">To let (t - existing variable) be given by (Q - equation name)</span>
<span class="plain">(documented at ph_letequation): (-</span>
<span class="plain">{-primitive-definition:solve-equation};</span>
<span class="plain">-).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP13"></a><b>&#167;13. </b>It is not explicit in the following definitions that Inform should typecheck
2019-03-17 14:40:57 +02:00
that the values held by these storage objects can be incremented or decremented
(as a room, say, cannot, but a number or a height can): Inform nevertheless
contains code which does this.
</p>
<pre class="display">
<span class="plain">To increase (S - storage) by (w - value)</span>
<span class="plain">(assignment operation)</span>
<span class="plain">(documented at ph_increase): (-</span>
<span class="plain">{-copy:S:+w};</span>
<span class="plain">-).</span>
<span class="plain">To decrease (S - storage) by (w - value)</span>
<span class="plain">(assignment operation)</span>
<span class="plain">(documented at ph_decrease): (-</span>
<span class="plain">{-copy:S:-w};</span>
<span class="plain">-).</span>
<span class="plain">To increment (S - storage)</span>
<span class="plain">(documented at ph_increment): (-</span>
<span class="plain">{-copy:S:+};</span>
<span class="plain">-).</span>
<span class="plain">To decrement (S - storage)</span>
<span class="plain">(documented at ph_decrement): (-</span>
<span class="plain">{-copy:S:-};</span>
<span class="plain">-).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP14"></a><b>&#167;14. </b>There are nine arithmetic operations, internally numbered 0 to 8, and
2019-03-17 14:40:57 +02:00
given verbal forms below. These are handled unusually in the type-checker
because they need to be more polymorphic than most phrases: Inform uses
dimension-checking to determine the kind of value resulting. (Thus a
height times a number is another height, and so on.)
</p>
<p class="inwebparagraph">The totalling code (12) is not structly to do with arithmetic in the same
way, but it's needed to flag the phrase for the Inform typechecker's special
attention.
</p>
<pre class="display">
<span class="plain">Section SR5/2/4 - Values - Arithmetic</span>
<span class="plain">To decide which arithmetic value is (X - arithmetic value) + (Y - arithmetic value)</span>
<span class="plain">(arithmetic operation 0)</span>
<span class="plain">(documented at ph_plus):</span>
<span class="plain">(- ({-arithmetic-operation:X:Y}) -).</span>
<span class="plain">To decide which arithmetic value is (X - arithmetic value) plus (Y - arithmetic value)</span>
<span class="plain">(arithmetic operation 0)</span>
<span class="plain">(documented at ph_plus):</span>
<span class="plain">(- ({-arithmetic-operation:X:Y}) -).</span>
<span class="plain">To decide which arithmetic value is (X - arithmetic value) - (Y - arithmetic value)</span>
<span class="plain">(arithmetic operation 1)</span>
<span class="plain">(documented at ph_minus):</span>
<span class="plain">(- ({-arithmetic-operation:X:Y}) -).</span>
<span class="plain">To decide which arithmetic value is (X - arithmetic value) minus (Y - arithmetic value)</span>
<span class="plain">(arithmetic operation 1)</span>
<span class="plain">(documented at ph_minus):</span>
<span class="plain">(- ({-arithmetic-operation:X:Y}) -).</span>
<span class="plain">To decide which arithmetic value is (X - arithmetic value) * (Y - arithmetic value)</span>
<span class="plain">(arithmetic operation 2)</span>
<span class="plain">(documented at ph_times):</span>
<span class="plain">(- ({-arithmetic-operation:X:Y}) -).</span>
<span class="plain">To decide which arithmetic value is (X - arithmetic value) times (Y - arithmetic value)</span>
<span class="plain">(arithmetic operation 2)</span>
<span class="plain">(documented at ph_times):</span>
<span class="plain">(- ({-arithmetic-operation:X:Y}) -).</span>
<span class="plain">To decide which arithmetic value is (X - arithmetic value) multiplied by (Y - arithmetic value)</span>
<span class="plain">(arithmetic operation 2)</span>
<span class="plain">(documented at ph_times):</span>
<span class="plain">(- ({-arithmetic-operation:X:Y}) -).</span>
<span class="plain">To decide which arithmetic value is (X - arithmetic value) / (Y - arithmetic value)</span>
<span class="plain">(arithmetic operation 3)</span>
<span class="plain">(documented at ph_divide):</span>
<span class="plain">(- ({-arithmetic-operation:X:Y}) -).</span>
<span class="plain">To decide which arithmetic value is (X - arithmetic value) divided by (Y - arithmetic value)</span>
<span class="plain">(arithmetic operation 3)</span>
<span class="plain">(documented at ph_divide):</span>
<span class="plain">(- ({-arithmetic-operation:X:Y}) -).</span>
<span class="plain">To decide which arithmetic value is remainder after dividing (X - arithmetic value)</span>
<span class="plain">by (Y - arithmetic value)</span>
<span class="plain">(arithmetic operation 4)</span>
<span class="plain">(documented at ph_remainder):</span>
<span class="plain">(- ({-arithmetic-operation:X:Y}) -).</span>
<span class="plain">To decide which arithmetic value is (X - arithmetic value) to the nearest (Y - arithmetic value)</span>
<span class="plain">(arithmetic operation 5)</span>
<span class="plain">(documented at ph_nearest):</span>
<span class="plain">(- ({-arithmetic-operation:X:Y}) -).</span>
<span class="plain">To decide which arithmetic value is the square root of (X - arithmetic value)</span>
<span class="plain">(arithmetic operation 6)</span>
<span class="plain">(documented at ph_squareroot):</span>
<span class="plain">(- ({-arithmetic-operation:X}) -).</span>
<span class="plain">To decide which arithmetic value is the cube root of (X - arithmetic value)</span>
<span class="plain">(arithmetic operation 8)</span>
<span class="plain">(documented at ph_cuberoot):</span>
<span class="plain">(- ({-arithmetic-operation:X}) -).</span>
<span class="plain">To decide which arithmetic value is total (p - arithmetic value valued property)</span>
<span class="plain">of (S - description of values)</span>
<span class="plain">(arithmetic operation 12)</span>
<span class="plain">(documented at ph_total):</span>
<span class="plain">(- {-primitive-definition:total-of} -).</span>
<span class="plain">Section SR5/2/4a - Values - Real Arithmetic (for Glulx only)</span>
<span class="plain">To say (R - a real number) to (N - number) decimal places</span>
<span class="plain">(documented at phs_realplaces):</span>
<span class="plain">(- Float({R}, {N}); -).</span>
<span class="plain">To say (R - a real number) in decimal notation</span>
<span class="plain">(documented at phs_decimal):</span>
<span class="plain">(- FloatDec({R}); -).</span>
<span class="plain">To say (R - a real number) to (N - number) decimal places in decimal notation</span>
<span class="plain">(documented at phs_decimalplaces):</span>
<span class="plain">(- FloatDec({R}, {N}); -).</span>
<span class="plain">To say (R - a real number) in scientific notation</span>
<span class="plain">(documented at phs_scientific):</span>
<span class="plain">(- FloatExp({R}); -).</span>
<span class="plain">To say (R - a real number) to (N - number) decimal places in scientific notation</span>
<span class="plain">(documented at phs_scientificplaces):</span>
<span class="plain">(- FloatExp({R}, {N}); -).</span>
<span class="plain">To decide which real number is the reciprocal of (R - a real number)</span>
<span class="plain">(documented at ph_reciprocal):</span>
<span class="plain">(- REAL_NUMBER_TY_Reciprocal({R}) -).</span>
<span class="plain">To decide which real number is the absolute value of (R - a real number)</span>
<span class="plain">(documented at ph_absolutevalue)</span>
<span class="plain">(this is the abs function):</span>
<span class="plain">(- REAL_NUMBER_TY_Abs({R}) -).</span>
<span class="plain">To decide which real number is the real square root of (R - a real number)</span>
<span class="plain">(arithmetic operation 7)</span>
<span class="plain">(documented at ph_realsquareroot)</span>
<span class="plain">(this is the root function inverse to rsqr):</span>
<span class="plain">(- REAL_NUMBER_TY_Root({R}) -).</span>
<span class="plain">To decide which real number is the real square of (R - a real number)</span>
<span class="plain">(this is the rsqr function inverse to root):</span>
<span class="plain">let x be given by x = R^2 where x is a real number;</span>
<span class="plain">decide on x.</span>
<span class="plain">To decide which real number is the ceiling of (R - a real number)</span>
<span class="plain">(documented at ph_ceiling)</span>
<span class="plain">(this is the ceiling function):</span>
<span class="plain">(- REAL_NUMBER_TY_Ceiling({R}) -).</span>
<span class="plain">To decide which real number is the floor of (R - a real number)</span>
<span class="plain">(documented at ph_floor)</span>
<span class="plain">(this is the floor function):</span>
<span class="plain">(- REAL_NUMBER_TY_Floor({R}) -).</span>
<span class="plain">To decide which number is (R - a real number) to the nearest whole number</span>
<span class="plain">(documented at ph_nearestwholenumber)</span>
<span class="plain">(this is the int function):</span>
<span class="plain">(- REAL_NUMBER_TY_to_NUMBER_TY({R}) -).</span>
<span class="plain">To decide which real number is the natural/-- logarithm of (R - a real number)</span>
<span class="plain">(documented at ph_logarithm)</span>
<span class="plain">(this is the log function inverse to exp):</span>
<span class="plain">(- REAL_NUMBER_TY_Log({R}) -).</span>
<span class="plain">To decide which real number is the logarithm to base (N - a number) of (R - a real number)</span>
<span class="plain">(documented at ph_logarithmto):</span>
<span class="plain">(- REAL_NUMBER_TY_BLog({R}, {N}) -).</span>
<span class="plain">To decide which real number is the exponential of (R - a real number)</span>
<span class="plain">(documented at ph_exp)</span>
<span class="plain">(this is the exp function inverse to log):</span>
<span class="plain">(- REAL_NUMBER_TY_Exp({R}) -).</span>
<span class="plain">To decide which real number is (R - a real number) to the power (P - a real number)</span>
<span class="plain">(documented at ph_power):</span>
<span class="plain">(- REAL_NUMBER_TY_Pow({R}, {P}) -).</span>
<span class="plain">Section SR5/2/4a - Values - Trigonometry (for Glulx only)</span>
<span class="plain">To decide which real number is (R - a real number) degrees</span>
<span class="plain">(documented at ph_degrees):</span>
<span class="plain">(- REAL_NUMBER_TY_Times({R}, $+0.0174532925) -).</span>
<span class="plain">To decide which real number is the sine of (R - a real number)</span>
<span class="plain">(documented at ph_sine)</span>
<span class="plain">(this is the sin function inverse to arcsin):</span>
<span class="plain">(- REAL_NUMBER_TY_Sin({R}) -).</span>
<span class="plain">To decide which real number is the cosine of (R - a real number)</span>
<span class="plain">(documented at ph_cosine)</span>
<span class="plain">(this is the cos function inverse to arccos):</span>
<span class="plain">(- REAL_NUMBER_TY_Cos({R}) -).</span>
<span class="plain">To decide which real number is the tangent of (R - a real number)</span>
<span class="plain">(documented at ph_tangent)</span>
<span class="plain">(this is the tan function inverse to arctan):</span>
<span class="plain">(- REAL_NUMBER_TY_Tan({R}) -).</span>
<span class="plain">To decide which real number is the arcsine of (R - a real number)</span>
<span class="plain">(documented at ph_arcsine)</span>
<span class="plain">(this is the arcsin function inverse to sin):</span>
<span class="plain">(- REAL_NUMBER_TY_Arcsin({R}) -).</span>
<span class="plain">To decide which real number is the arccosine of (R - a real number)</span>
<span class="plain">(documented at ph_arccosine)</span>
<span class="plain">(this is the arccos function inverse to cos):</span>
<span class="plain">(- REAL_NUMBER_TY_Arccos({R}) -).</span>
<span class="plain">To decide which real number is the arctangent of (R - a real number)</span>
<span class="plain">(documented at ph_arctangent)</span>
<span class="plain">(this is the arctan function inverse to tan):</span>
<span class="plain">(- REAL_NUMBER_TY_Arctan({R}) -).</span>
<span class="plain">Section SR5/2/4a - Values - Hyperbolic functions (for Glulx only)</span>
<span class="plain">To decide which real number is the hyperbolic sine of (R - a real number)</span>
<span class="plain">(documented at ph_hyperbolicsine)</span>
<span class="plain">(this is the sinh function inverse to arcsinh):</span>
<span class="plain">(- REAL_NUMBER_TY_Sinh({R}) -).</span>
<span class="plain">To decide which real number is the hyperbolic cosine of (R - a real number)</span>
<span class="plain">(documented at ph_hyperboliccosine)</span>
<span class="plain">(this is the cosh function inverse to arccosh):</span>
<span class="plain">(- REAL_NUMBER_TY_Cosh({R}) -).</span>
<span class="plain">To decide which real number is the hyperbolic tangent of (R - a real number)</span>
<span class="plain">(documented at ph_hyperbolictangent)</span>
<span class="plain">(this is the tanh function inverse to arctanh):</span>
<span class="plain">(- REAL_NUMBER_TY_Tanh({R}) -).</span>
<span class="plain">To decide which real number is the hyperbolic arcsine of (R - a real number)</span>
<span class="plain">(documented at ph_hyperbolicarcsine)</span>
<span class="plain">(this is the arcsinh function inverse to sinh):</span>
<span class="plain">let x be given by x = log(R + root(R^2 + 1)) where x is a real number;</span>
<span class="plain">decide on x.</span>
<span class="plain">To decide which real number is the hyperbolic arccosine of (R - a real number)</span>
<span class="plain">(documented at ph_hyperbolicarccosine)</span>
<span class="plain">(this is the arccosh function inverse to cosh):</span>
<span class="plain">let x be given by x = log(R + root(R^2 - 1)) where x is a real number;</span>
<span class="plain">decide on x.</span>
<span class="plain">To decide which real number is the hyperbolic arctangent of (R - a real number)</span>
<span class="plain">(documented at ph_hyperbolicarctangent)</span>
<span class="plain">(this is the arctanh function inverse to tanh):</span>
<span class="plain">let x be given by x = 0.5*(log(1+R) - log(1-R)) where x is a real number;</span>
<span class="plain">decide on x.</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP15"></a><b>&#167;15. </b>Some of the things we can do with enumerations, others being listed under
2019-03-17 14:40:57 +02:00
randomness below.
</p>
<pre class="display">
<span class="plain">Section SR5/2/5 - Values - Enumerations</span>
<span class="plain">To decide which number is number of (S - description of values)</span>
<span class="plain">(documented at ph_numberof):</span>
<span class="plain">(- {-primitive-definition:number-of} -).</span>
<span class="plain">To decide which K is (name of kind of enumerated value K) after (X - K)</span>
<span class="plain">(documented at ph_enumafter):</span>
<span class="plain">(- {-next-routine:K}({X}) -).</span>
<span class="plain">To decide which K is (name of kind of enumerated value K) before (X - K)</span>
<span class="plain">(documented at ph_enumbefore):</span>
<span class="plain">(- {-previous-routine:K}({X}) -).</span>
<span class="plain">To decide which K is the first value of (name of kind of enumerated value K)</span>
<span class="plain">(documented at ph_enumfirst):</span>
<span class="plain">decide on the default value of K.</span>
<span class="plain">To decide which K is the last value of (name of kind of enumerated value K)</span>
<span class="plain">(documented at ph_enumlast):</span>
<span class="plain">decide on K before the default value of K.</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP16"></a><b>&#167;16. </b>The following exists only to convert a condition to a value, and is
2019-03-17 14:40:57 +02:00
needed because I7 does not silently cast from one to the other in the way
that C would.
</p>
<pre class="display">
<span class="plain">Section SR5/2/6 - Values - Truth states</span>
<span class="plain">To decide what truth state is whether or not (C - condition)</span>
<span class="plain">(documented at ph_whether):</span>
<span class="plain">(- ({C}) -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP17"></a><b>&#167;17. </b>Random numbers and random items chosen from sets of objects matching a
2019-03-17 14:40:57 +02:00
given description ("a random closed door").
</p>
<pre class="display">
<span class="plain">Section SR5/2/7 - Values - Randomness</span>
<span class="plain">To decide which K is a/-- random (S - description of values of kind K)</span>
<span class="plain">(documented at ph_randomdesc):</span>
<span class="plain">(- {-primitive-definition:random-of} -).</span>
<span class="plain">To decide which K is a random (name of kind of arithmetic value K) between (first value - K) and (second value - K)</span>
<span class="plain">(documented at ph_randombetween):</span>
<span class="plain">(- {-ranger-routine:K}({first value}, {second value}) -).</span>
<span class="plain">To decide which K is a random (name of kind of arithmetic value K) from (first value - K) to (second value - K)</span>
<span class="plain">(documented at ph_randombetween):</span>
<span class="plain">(- {-ranger-routine:K}({first value}, {second value}) -).</span>
<span class="plain">To decide which K is a random (name of kind of enumerated value K) between (first value - K) and (second value - K)</span>
<span class="plain">(documented at ph_randombetween):</span>
<span class="plain">(- {-ranger-routine:K}({first value}, {second value}) -).</span>
<span class="plain">To decide which K is a random (name of kind of enumerated value K) from (first value - K) to (second value - K)</span>
<span class="plain">(documented at ph_randombetween):</span>
<span class="plain">(- {-ranger-routine:K}({first value}, {second value}) -).</span>
<span class="plain">To decide whether a random chance of (N - number) in (M - number) succeeds</span>
<span class="plain">(documented at ph_randomchance):</span>
<span class="plain">(- (GenerateRandomNumber(1, {M}) &lt;= {N}) -).</span>
<span class="plain">To seed the random-number generator with (N - number)</span>
<span class="plain">(documented at ph_seed):</span>
<span class="plain">(- VM_Seed_RNG({N}); -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP18"></a><b>&#167;18. Tables. </b>And off we go into the world of tables, the code for which is all in
2019-03-17 14:40:57 +02:00
"Tables.i6t". Note that changing a table entry is not here: it's above,
with the phrases for changing other storage objects.
</p>
<pre class="display">
<span class="plain">Section SR5/2/8 - Values - Tables</span>
<span class="plain">To choose a/the/-- row (N - number) in/from (T - table name)</span>
<span class="plain">(documented at ph_chooserow):</span>
<span class="plain">(- {-my:ct_0} = {T}; {-my:ct_1} = {N}; -).</span>
<span class="plain">To choose a/the/-- row with (TC - K valued table column) of (w - value of kind K)</span>
<span class="plain">in/from (T - table name)</span>
<span class="plain">(documented at ph_chooserowwith):</span>
<span class="plain">(- {-my:ct_0} = {T}; {-my:ct_1} = TableRowCorr(ct_0, {TC}, {w}); -).</span>
<span class="plain">To choose a/the/-- blank row in/from (T - table name)</span>
<span class="plain">(documented at ph_chooseblankrow):</span>
<span class="plain">(- {-my:ct_0} = {T}; {-my:ct_1} = TableBlankRow(ct_0); -).</span>
<span class="plain">To choose a/the/-- random row in/from (T - table name)</span>
<span class="plain">(documented at ph_chooserandomrow):</span>
<span class="plain">(- {-my:ct_0} = {T}; {-my:ct_1} = TableRandomRow(ct_0); -).</span>
<span class="plain">To decide which number is number of rows in/from (T - table name)</span>
<span class="plain">(documented at ph_numrows):</span>
<span class="plain">(- TableRows({T}) -).</span>
<span class="plain">To decide which number is number of blank rows in/from (T - table name)</span>
<span class="plain">(documented at ph_numblank):</span>
<span class="plain">(- TableBlankRows({T}) -).</span>
<span class="plain">To decide which number is number of filled rows in/from (T - table name)</span>
<span class="plain">(documented at ph_numfilled):</span>
<span class="plain">(- TableFilledRows({T}) -).</span>
<span class="plain">To decide if there is (TR - table-reference)</span>
<span class="plain">(documented at ph_thereis):</span>
2019-04-10 04:13:29 +03:00
<span class="plain">(- ({-reference-exists:TR}) -).</span>
2019-03-17 14:40:57 +02:00
<span class="plain">To decide if there is no (TR - table-reference)</span>
<span class="plain">(documented at ph_thereisno):</span>
2019-04-10 04:13:29 +03:00
<span class="plain">(- ({-reference-exists:TR} == false) -).</span>
2019-03-17 14:40:57 +02:00
<span class="plain">To blank out (tr - table-reference)</span>
<span class="plain">(documented at ph_blankout):</span>
<span class="plain">(- {-by-reference-blank-out:tr}; -).</span>
<span class="plain">To blank out the whole row</span>
<span class="plain">(documented at ph_blankoutrow):</span>
<span class="plain">(- TableBlankOutRow({-my:ct_0}, {-my:ct_1}); -).</span>
<span class="plain">To blank out the whole (TC - table column) in/from (T - table name)</span>
<span class="plain">(documented at ph_blankoutcol):</span>
<span class="plain">(- TableBlankOutColumn({T}, {TC}); -).</span>
<span class="plain">To blank out the whole of (T - table name)</span>
<span class="plain">(documented at ph_blankouttable):</span>
<span class="plain">(- TableBlankOutAll({T}); -).</span>
<span class="plain">To showme the contents of (T - table name)</span>
<span class="plain">(documented at ph_showmetable):</span>
<span class="plain">(- TableDebug({T}); -).</span>
<span class="plain">To say the/-- current table row</span>
<span class="plain">(documented at phs_currenttablerow):</span>
<span class="plain">(- TableRowDebug({-my:ct_0}, {-my:ct_1}); -).</span>
<span class="plain">To say row (N - number) in/from (T - table name)</span>
<span class="plain">(documented at phs_tablerow):</span>
<span class="plain">(- TableRowDebug({T}, {N}); -).</span>
<span class="plain">To say (TC - table column) in/from (T - table name)</span>
<span class="plain">(documented at phs_tablecolumn):</span>
<span class="plain">(- TableColumnDebug({T}, {TC}); -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP19"></a><b>&#167;19. </b>Sorting.
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/2/9 - Values - Sorting tables</span>
<span class="plain">To sort (T - table name) in/into random order</span>
<span class="plain">(documented at ph_sortrandom):</span>
<span class="plain">(- TableShuffle({T}); -).</span>
<span class="plain">To sort (T - table name) in/into (TC - table column) order</span>
<span class="plain">(documented at ph_sortcolumn):</span>
<span class="plain">(- TableSort({T}, {TC}, 1); -).</span>
<span class="plain">To sort (T - table name) in/into reverse (TC - table column) order</span>
<span class="plain">(documented at ph_sortcolumnreverse):</span>
<span class="plain">(- TableSort({T}, {TC}, -1); -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP20"></a><b>&#167;20. Breaking down text. </b>As repetitive as the following is, it's much simpler and less prone to
2019-03-17 14:40:57 +02:00
possible namespace trouble if we don't define kinds of value for the different
structural levels of text (character, word, punctuated word, etc.).
</p>
<pre class="display">
<span class="plain">Section SR5/2/10 - Values - Breaking down text</span>
<span class="plain">To decide what number is the number of characters in (T - text)</span>
<span class="plain">(documented at ph_numchars):</span>
<span class="plain">(- TEXT_TY_BlobAccess({-by-reference:T}, CHR_BLOB) -).</span>
<span class="plain">To decide what number is the number of words in (T - text)</span>
<span class="plain">(documented at ph_numwords):</span>
<span class="plain">(- TEXT_TY_BlobAccess({-by-reference:T}, WORD_BLOB) -).</span>
<span class="plain">To decide what number is the number of punctuated words in (T - text)</span>
<span class="plain">(documented at ph_numpwords):</span>
<span class="plain">(- TEXT_TY_BlobAccess({-by-reference:T}, PWORD_BLOB) -).</span>
<span class="plain">To decide what number is the number of unpunctuated words in (T - text)</span>
<span class="plain">(documented at ph_numupwords):</span>
<span class="plain">(- TEXT_TY_BlobAccess({-by-reference:T}, UWORD_BLOB) -).</span>
<span class="plain">To decide what number is the number of lines in (T - text)</span>
<span class="plain">(documented at ph_numlines):</span>
<span class="plain">(- TEXT_TY_BlobAccess({-by-reference:T}, LINE_BLOB) -).</span>
<span class="plain">To decide what number is the number of paragraphs in (T - text)</span>
<span class="plain">(documented at ph_numparas):</span>
<span class="plain">(- TEXT_TY_BlobAccess({-by-reference:T}, PARA_BLOB) -).</span>
<span class="plain">To decide what text is character number (N - a number) in (T - text)</span>
<span class="plain">(documented at ph_charnum):</span>
<span class="plain">(- TEXT_TY_GetBlob({-new:text}, {-by-reference:T}, {N}, CHR_BLOB) -).</span>
<span class="plain">To decide what text is word number (N - a number) in (T - text)</span>
<span class="plain">(documented at ph_wordnum):</span>
<span class="plain">(- TEXT_TY_GetBlob({-new:text}, {-by-reference:T}, {N}, WORD_BLOB) -).</span>
<span class="plain">To decide what text is punctuated word number (N - a number) in (T - text)</span>
<span class="plain">(documented at ph_pwordnum):</span>
<span class="plain">(- TEXT_TY_GetBlob({-new:text}, {-by-reference:T}, {N}, PWORD_BLOB) -).</span>
<span class="plain">To decide what text is unpunctuated word number (N - a number) in (T - text)</span>
<span class="plain">(documented at ph_upwordnum):</span>
<span class="plain">(- TEXT_TY_GetBlob({-new:text}, {-by-reference:T}, {N}, UWORD_BLOB) -).</span>
<span class="plain">To decide what text is line number (N - a number) in (T - text)</span>
<span class="plain">(documented at ph_linenum):</span>
<span class="plain">(- TEXT_TY_GetBlob({-new:text}, {-by-reference:T}, {N}, LINE_BLOB) -).</span>
<span class="plain">To decide what text is paragraph number (N - a number) in (T - text)</span>
<span class="plain">(documented at ph_paranum):</span>
<span class="plain">(- TEXT_TY_GetBlob({-new:text}, {-by-reference:T}, {N}, PARA_BLOB) -).</span>
<span class="plain">To decide what text is the substituted form of (T - text)</span>
<span class="plain">(documented at ph_subform):</span>
<span class="plain">(- TEXT_TY_SubstitutedForm({-new:text}, {-by-reference:T}) -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP21"></a><b>&#167;21. Matching text. </b>A common matching engine is used for matching plain text...
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/2/11 - Values - Matching text</span>
<span class="plain">To decide if (T - text) exactly matches the text (find - text),</span>
<span class="plain">case insensitively</span>
<span class="plain">(documented at ph_exactlymatches):</span>
<span class="plain">(- TEXT_TY_Replace_RE(CHR_BLOB,{-by-reference:T},{-by-reference:find},0,{phrase options},1) -).</span>
<span class="plain">To decide if (T - text) matches the text (find - text),</span>
<span class="plain">case insensitively</span>
<span class="plain">(documented at ph_matches):</span>
<span class="plain">(- TEXT_TY_Replace_RE(CHR_BLOB,{-by-reference:T},{-by-reference:find},0,{phrase options}) -).</span>
<span class="plain">To decide what number is number of times (T - text) matches the text</span>
<span class="plain">(find - text), case insensitively</span>
<span class="plain">(documented at ph_nummatches):</span>
<span class="plain">(- TEXT_TY_Replace_RE(CHR_BLOB,{-by-reference:T},{-by-reference:find},1,{phrase options}) -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP22"></a><b>&#167;22. </b>...and for regular expressions, though here we also have access to the
2019-03-17 14:40:57 +02:00
exact text which matched (not interesting in the plain text case since it's
the same as the search text, up to case at least), and the values of matched
subexpressions (which the plain text case doesn't have).
</p>
<pre class="display">
<span class="plain">To decide if (T - text) exactly matches the regular expression (find - text),</span>
<span class="plain">case insensitively</span>
<span class="plain">(documented at ph_exactlymatchesre):</span>
<span class="plain">(- TEXT_TY_Replace_RE(REGEXP_BLOB,{-by-reference:T},{-by-reference:find},0,{phrase options},1) -).</span>
<span class="plain">To decide if (T - text) matches the regular expression (find - text),</span>
<span class="plain">case insensitively</span>
<span class="plain">(documented at ph_matchesre):</span>
<span class="plain">(- TEXT_TY_Replace_RE(REGEXP_BLOB,{-by-reference:T},{-by-reference:find},0,{phrase options}) -).</span>
<span class="plain">To decide what text is text matching regular expression</span>
<span class="plain">(documented at ph_matchtext):</span>
<span class="plain">(- TEXT_TY_RE_GetMatchVar(0) -).</span>
<span class="plain">To decide what text is text matching subexpression (N - a number)</span>
<span class="plain">(documented at ph_subexpressiontext):</span>
<span class="plain">(- TEXT_TY_RE_GetMatchVar({N}) -).</span>
<span class="plain">To decide what number is number of times (T - text) matches the regular expression</span>
<span class="plain">(find - text),case insensitively</span>
<span class="plain">(documented at ph_nummatchesre):</span>
<span class="plain">(- TEXT_TY_Replace_RE(REGEXP_BLOB,{-by-reference:T},{-by-reference:find},1,{phrase options}) -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP23"></a><b>&#167;23. Replacing text. </b>The same engine, in "RegExp.i6t", handles replacement.
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/2/12 - Values - Replacing text</span>
<span class="plain">To replace the text (find - text) in (T - text) with (replace - text),</span>
<span class="plain">case insensitively</span>
<span class="plain">(documented at ph_replace):</span>
<span class="plain">(- TEXT_TY_Replace_RE(CHR_BLOB, {-lvalue-by-reference:T}, {-by-reference:find},</span>
<span class="plain">{-by-reference:replace}, {phrase options}); -).</span>
<span class="plain">To replace the regular expression (find - text) in (T - text) with</span>
<span class="plain">(replace - text), case insensitively</span>
<span class="plain">(documented at ph_replacere):</span>
<span class="plain">(- TEXT_TY_Replace_RE(REGEXP_BLOB, {-lvalue-by-reference:T}, {-by-reference:find},</span>
<span class="plain">{-by-reference:replace}, {phrase options}); -).</span>
<span class="plain">To replace the word (find - text) in (T - text) with</span>
<span class="plain">(replace - text)</span>
<span class="plain">(documented at ph_replacewordin):</span>
<span class="plain">(- TEXT_TY_ReplaceText(WORD_BLOB, {-lvalue-by-reference:T}, {-by-reference:find}, {-by-reference:replace}); -).</span>
<span class="plain">To replace the punctuated word (find - text) in (T - text)</span>
<span class="plain">with (replace - text)</span>
<span class="plain">(documented at ph_replacepwordin):</span>
<span class="plain">(- TEXT_TY_ReplaceText(PWORD_BLOB, {-lvalue-by-reference:T}, {-by-reference:find}, {-by-reference:replace}); -).</span>
<span class="plain">To replace character number (N - a number) in (T - text)</span>
<span class="plain">with (replace - text)</span>
<span class="plain">(documented at ph_replacechar):</span>
<span class="plain">(- TEXT_TY_ReplaceBlob(CHR_BLOB, {-lvalue-by-reference:T}, {N}, {-by-reference:replace}); -).</span>
<span class="plain">To replace word number (N - a number) in (T - text)</span>
<span class="plain">with (replace - text)</span>
<span class="plain">(documented at ph_replaceword):</span>
<span class="plain">(- TEXT_TY_ReplaceBlob(WORD_BLOB, {-lvalue-by-reference:T}, {N}, {-by-reference:replace}); -).</span>
<span class="plain">To replace punctuated word number (N - a number) in (T - text)</span>
<span class="plain">with (replace - text)</span>
<span class="plain">(documented at ph_replacepword):</span>
<span class="plain">(- TEXT_TY_ReplaceBlob(PWORD_BLOB, {-lvalue-by-reference:T}, {N}, {-by-reference:replace}); -).</span>
<span class="plain">To replace unpunctuated word number (N - a number) in (T - text)</span>
<span class="plain">with (replace - text)</span>
<span class="plain">(documented at ph_replaceupword):</span>
<span class="plain">(- TEXT_TY_ReplaceBlob(UWORD_BLOB, {-lvalue-by-reference:T}, {N}, {-by-reference:replace}); -).</span>
<span class="plain">To replace line number (N - a number) in (T - text) with (replace - text)</span>
<span class="plain">(documented at ph_replaceline):</span>
<span class="plain">(- TEXT_TY_ReplaceBlob(LINE_BLOB, {-lvalue-by-reference:T}, {N}, {-by-reference:replace}); -).</span>
<span class="plain">To replace paragraph number (N - a number) in (T - text) with (replace - text)</span>
<span class="plain">(documented at ph_replacepara):</span>
<span class="plain">(- TEXT_TY_ReplaceBlob(PARA_BLOB, {-lvalue-by-reference:T}, {N}, {-by-reference:replace}); -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP24"></a><b>&#167;24. Casing of text. </b></p>
2019-03-17 14:40:57 +02:00
<pre class="display">
<span class="plain">Section SR5/2/13 - Values - Casing of text</span>
<span class="plain">To decide what text is (T - text) in lower case</span>
<span class="plain">(documented at ph_lowercase):</span>
<span class="plain">(- TEXT_TY_CharactersToCase({-new:text}, {-by-reference:T}, 0) -).</span>
<span class="plain">To decide what text is (T - text) in upper case</span>
<span class="plain">(documented at ph_uppercase):</span>
<span class="plain">(- TEXT_TY_CharactersToCase({-new:text}, {-by-reference:T}, 1) -).</span>
<span class="plain">To decide what text is (T - text) in title case</span>
<span class="plain">(documented at ph_titlecase):</span>
<span class="plain">(- TEXT_TY_CharactersToCase({-new:text}, {-by-reference:T}, 2) -).</span>
<span class="plain">To decide what text is (T - text) in sentence case</span>
<span class="plain">(documented at ph_sentencecase):</span>
<span class="plain">(- TEXT_TY_CharactersToCase({-new:text}, {-by-reference:T}, 3) -).</span>
<span class="plain">To decide if (T - text) is in lower case</span>
<span class="plain">(documented at ph_inlower):</span>
<span class="plain">(- TEXT_TY_CharactersOfCase({-by-reference:T}, 0) -).</span>
<span class="plain">To decide if (T - text) is in upper case</span>
<span class="plain">(documented at ph_inupper):</span>
<span class="plain">(- TEXT_TY_CharactersOfCase({-by-reference:T}, 1) -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP25"></a><b>&#167;25. Adaptive text. </b></p>
2019-03-17 14:40:57 +02:00
<pre class="display">
<span class="plain">Section SR5/2/14 - Values - Adaptive text</span>
<span class="plain">To say infinitive of (V - a verb)</span>
<span class="plain">(documented at phs_infinitive):</span>
<span class="plain">(- {V}(1); -).</span>
<span class="plain">To say past participle of (V - a verb)</span>
<span class="plain">(documented at phs_pastpart):</span>
<span class="plain">(- {V}(2); -).</span>
<span class="plain">To say present participle of (V - a verb)</span>
<span class="plain">(documented at phs_prespart):</span>
<span class="plain">(- {V}(3); -).</span>
<span class="plain">To say adapt (V - verb)</span>
<span class="plain">(documented at phs_adapt):</span>
<span class="plain">(- {V}(CV_POS, PNToVP(), story_tense); -).</span>
<span class="plain">To say adapt (V - verb) in (T - grammatical tense)</span>
<span class="plain">(documented at phs_adaptt):</span>
<span class="plain">(- {V}(CV_POS, PNToVP(), {T}); -).</span>
<span class="plain">To say adapt (V - verb) from (P - narrative viewpoint)</span>
<span class="plain">(documented at phs_adaptv):</span>
<span class="plain">(- {V}(CV_POS, {P}, story_tense); -).</span>
<span class="plain">To say adapt (V - verb) in (T - grammatical tense) from (P - narrative viewpoint)</span>
<span class="plain">(documented at phs_adaptvt):</span>
<span class="plain">(- {V}(CV_POS, {P}, {T}); -).</span>
<span class="plain">To say negate (V - verb)</span>
<span class="plain">(documented at phs_negate):</span>
<span class="plain">(- {V}(CV_NEG, PNToVP(), story_tense); -).</span>
<span class="plain">To say negate (V - verb) in (T - grammatical tense)</span>
<span class="plain">(documented at phs_negatet):</span>
<span class="plain">(- {V}(CV_NEG, PNToVP(), {T}); -).</span>
<span class="plain">To say negate (V - verb) from (P - narrative viewpoint)</span>
<span class="plain">(documented at phs_negatev):</span>
<span class="plain">(- {V}(CV_NEG, {P}, story_tense); -).</span>
<span class="plain">To say negate (V - verb) in (T - grammatical tense) from (P - narrative viewpoint)</span>
<span class="plain">(documented at phs_negatevt):</span>
<span class="plain">(- {V}(CV_NEG, {P}, {T}); -).</span>
<span class="plain">To decide which relation of objects is meaning of (V - a verb): (- {V}(CV_MEANING) -).</span>
<span class="plain">To say here</span>
<span class="plain">(documented at phs_here):</span>
<span class="plain">say "[if story tense is present tense]here[otherwise]there".</span>
<span class="plain">To say now</span>
<span class="plain">(documented at phs_now):</span>
<span class="plain">say "[if story tense is present tense]now[otherwise]then".</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP26"></a><b>&#167;26. Lists. </b>The following are all for adding and removing values to dynamic lists:
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/2/15 - Values - Lists</span>
<span class="plain">To add (new entry - K) to (L - list of values of kind K), if absent</span>
<span class="plain">(documented at ph_addtolist):</span>
<span class="plain">(- LIST_OF_TY_InsertItem({-lvalue-by-reference:L}, {new entry}, 0, 0, {phrase options}); -).</span>
<span class="plain">To add (new entry - K) at entry (E - number) in (L - list of values of kind K), if absent</span>
<span class="plain">(documented at ph_addatentry):</span>
<span class="plain">(- LIST_OF_TY_InsertItem({-lvalue-by-reference:L}, {new entry}, 1, {E}, {phrase options}); -).</span>
<span class="plain">To add (LX - list of Ks) to (L - list of values of kind K), if absent</span>
<span class="plain">(documented at ph_addlisttolist):</span>
<span class="plain">(- LIST_OF_TY_AppendList({-lvalue-by-reference:L}, {-by-reference:LX}, 0, 0, {phrase options}); -).</span>
<span class="plain">To add (LX - list of Ks) at entry (E - number) in (L - list of values of kind K)</span>
<span class="plain">(documented at ph_addlistatentry):</span>
<span class="plain">(- LIST_OF_TY_AppendList({-lvalue-by-reference:L}, {-by-reference:LX}, 1, {E}, 0); -).</span>
<span class="plain">To remove (existing entry - K) from (L - list of values of kind K), if present</span>
<span class="plain">(documented at ph_remfromlist):</span>
<span class="plain">(- LIST_OF_TY_RemoveValue({-lvalue-by-reference:L}, {existing entry}, {phrase options}); -).</span>
<span class="plain">To remove (N - list of Ks) from (L - list of values of kind K), if present</span>
<span class="plain">(documented at ph_remlistfromlist):</span>
<span class="plain">(- LIST_OF_TY_Remove_List({-lvalue-by-reference:L}, {-by-reference:N}, {phrase options}); -).</span>
<span class="plain">To remove entry (N - number) from (L - list of values), if present</span>
<span class="plain">(documented at ph_rementry):</span>
<span class="plain">(- LIST_OF_TY_RemoveItemRange({-lvalue-by-reference:L}, {N}, {N}, {phrase options}); -).</span>
<span class="plain">To remove entries (N - number) to (N2 - number) from (L - list of values), if present</span>
<span class="plain">(documented at ph_rementries):</span>
<span class="plain">(- LIST_OF_TY_RemoveItemRange({-lvalue-by-reference:L}, {N}, {N2}, {phrase options}); -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP27"></a><b>&#167;27. </b>Searching a list is implemented in a somewhat crude way at present, and the
2019-03-17 14:40:57 +02:00
following syntax may later be replaced with a suitable verb "to be listed
in", so that there's no need to imitate.
</p>
<pre class="display">
<span class="plain">To decide if (N - K) is listed in (L - list of values of kind K)</span>
<span class="plain">(documented at ph_islistedin):</span>
<span class="plain">(- (LIST_OF_TY_FindItem({-by-reference:L}, {N})) -).</span>
<span class="plain">To decide if (N - K) is not listed in (L - list of values of kind K)</span>
<span class="plain">(documented at ph_isnotlistedin):</span>
<span class="plain">(- (LIST_OF_TY_FindItem({-by-reference:L}, {N}) == false) -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP28"></a><b>&#167;28. </b>The following are casts to and from other kinds or objects. Lists
2019-03-17 14:40:57 +02:00
are not the only I7 way to hold list-like data, because sometimes the memory
requirements for dynamic lists are beyond what the virtual machine can sustain.
</p>
<p class="inwebparagraph"></p>
<ul class="items"><li>(a) A description is a representation of a set of objects by means of a
predicate (e.g., "open unlocked doors"), and it converts into a list of
current members (in creation order), but there's no reverse process.
</li></ul>
<ul class="items"><li>(b) The multiple object list is a data structure used in the parser when
processing commands like TAKE ALL.
</li></ul>
<pre class="display">
<span class="plain">To decide what list of Ks is the list of (D - description of values of kind K)</span>
<span class="plain">(documented at ph_listofdesc):</span>
<span class="plain">(- {-new-list-of:list of K} -).</span>
<span class="plain">To decide what list of objects is the multiple object list</span>
<span class="plain">(documented at ph_multipleobjectlist):</span>
<span class="plain">(- LIST_OF_TY_Mol({-new:list of objects}) -).</span>
<span class="plain">To alter the multiple object list to (L - list of objects)</span>
<span class="plain">(documented at ph_altermultipleobjectlist):</span>
<span class="plain">(- LIST_OF_TY_Set_Mol({-by-reference:L}); -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP29"></a><b>&#167;29. </b>Determining and setting the length:
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/2/16 - Values - Length of lists</span>
<span class="plain">To decide what number is the number of entries in/of (L - a list of values)</span>
<span class="plain">(documented at ph_numberentries):</span>
<span class="plain">(- LIST_OF_TY_GetLength({-by-reference:L}) -).</span>
<span class="plain">To truncate (L - a list of values) to (N - a number) entries/entry</span>
<span class="plain">(documented at ph_truncate):</span>
<span class="plain">(- LIST_OF_TY_SetLength({-lvalue-by-reference:L}, {N}, -1, 1); -).</span>
<span class="plain">To truncate (L - a list of values) to the first (N - a number) entries/entry</span>
<span class="plain">(documented at ph_truncatefirst):</span>
<span class="plain">(- LIST_OF_TY_SetLength({-lvalue-by-reference:L}, {N}, -1, 1); -).</span>
<span class="plain">To truncate (L - a list of values) to the last (N - a number) entries/entry</span>
<span class="plain">(documented at ph_truncatelast):</span>
<span class="plain">(- LIST_OF_TY_SetLength({-lvalue-by-reference:L}, {N}, -1, -1); -).</span>
<span class="plain">To extend (L - a list of values) to (N - a number) entries/entry</span>
<span class="plain">(documented at ph_extend):</span>
<span class="plain">(- LIST_OF_TY_SetLength({-lvalue-by-reference:L}, {N}, 1); -).</span>
<span class="plain">To change (L - a list of values) to have (N - a number) entries/entry</span>
<span class="plain">(documented at ph_changelength):</span>
<span class="plain">(- LIST_OF_TY_SetLength({-lvalue-by-reference:L}, {N}, 0); -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP30"></a><b>&#167;30. </b>Easy but useful list operations:
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/2/17 - Values - Reversing and rotating lists</span>
<span class="plain">To reverse (L - a list of values)</span>
<span class="plain">(documented at ph_reverselist):</span>
<span class="plain">(- LIST_OF_TY_Reverse({-lvalue-by-reference:L}); -).</span>
<span class="plain">To rotate (L - a list of values)</span>
<span class="plain">(documented at ph_rotatelist):</span>
<span class="plain">(- LIST_OF_TY_Rotate({-lvalue-by-reference:L}, 0); -).</span>
<span class="plain">To rotate (L - a list of values) backwards</span>
<span class="plain">(documented at ph_rotatelistback):</span>
<span class="plain">(- LIST_OF_TY_Rotate({-lvalue-by-reference:L}, 1); -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP31"></a><b>&#167;31. </b>Sorting ultimately uses a common sorting mechanism, in "Sort.i6t", which
2019-03-17 14:40:57 +02:00
handles both lists and tables.
</p>
<pre class="display">
<span class="plain">Section SR5/2/18 - Values - Sorting lists</span>
<span class="plain">To sort (L - a list of values)</span>
<span class="plain">(documented at ph_sortlist):</span>
<span class="plain">(- LIST_OF_TY_Sort({-lvalue-by-reference:L}, 1); -).</span>
<span class="plain">To sort (L - a list of values) in/into reverse order</span>
<span class="plain">(documented at ph_sortlistreverse):</span>
<span class="plain">(- LIST_OF_TY_Sort({-lvalue-by-reference:L}, -1); -).</span>
<span class="plain">To sort (L - a list of values) in/into random order</span>
<span class="plain">(documented at ph_sortlistrandom):</span>
<span class="plain">(- LIST_OF_TY_Sort({-lvalue-by-reference:L}, 2); -).</span>
<span class="plain">To sort (L - a list of objects) in/into (P - property) order</span>
<span class="plain">(documented at ph_sortlistproperty):</span>
<span class="plain">(- LIST_OF_TY_Sort({-lvalue-by-reference:L}, 1, {P}, {-property-holds-block-value:P}); -).</span>
<span class="plain">To sort (L - a list of objects) in/into reverse (P - property) order</span>
<span class="plain">(documented at ph_sortlistpropertyreverse):</span>
<span class="plain">(- LIST_OF_TY_Sort({-lvalue-by-reference:L}, -1, {P}, {-property-holds-block-value:P}); -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP32"></a><b>&#167;32. </b>Relations are the final data structure given here. In some ways they are
2019-03-17 14:40:57 +02:00
the most fundamental of all, but they're not either set or tested by
procedural phrases &mdash; they lie in the linguistic structure of conditions.
So all we have here are the route-finding phrases:
</p>
<pre class="display">
<span class="plain">Section SR5/2/19 - Values - Relations</span>
<span class="plain">To show relation (R - relation)</span>
<span class="plain">(documented at ph_showrelation):</span>
<span class="plain">(- {-show-me:R}; RelationTest({-by-reference:R}, RELS_SHOW); -).</span>
<span class="plain">To decide which object is next step via (R - relation of objects)</span>
<span class="plain">from (O1 - object) to (O2 - object)</span>
<span class="plain">(documented at ph_nextstep):</span>
<span class="plain">(- RelationRouteTo({-by-reference:R},{O1},{O2},false) -).</span>
<span class="plain">To decide which number is number of steps via (R - relation of objects)</span>
<span class="plain">from (O1 - object) to (O2 - object)</span>
<span class="plain">(documented at ph_numbersteps):</span>
<span class="plain">(- RelationRouteTo({-by-reference:R},{O1},{O2},true) -).</span>
<span class="plain">To decide which list of Ks is list of (name of kind of value K)</span>
<span class="plain">that/which/whom (R - relation of Ks to values of kind L) relates</span>
<span class="plain">(documented at ph_leftdomain):</span>
<span class="plain">(- RelationTest({-by-reference:R}, RELS_LIST, {-new:list of K}, RLIST_ALL_X) -).</span>
<span class="plain">To decide which list of Ls is list of (name of kind of value L)</span>
<span class="plain">to which/whom (R - relation of values of kind K to Ls) relates</span>
<span class="plain">(documented at ph_rightdomain):</span>
<span class="plain">(- RelationTest({-by-reference:R}, RELS_LIST, {-new:list of L}, RLIST_ALL_Y) -). [1]</span>
<span class="plain">To decide which list of Ls is list of (name of kind of value L)</span>
<span class="plain">that/which/whom (R - relation of values of kind K to Ls) relates to</span>
<span class="plain">(documented at ph_rightdomain):</span>
<span class="plain">(- RelationTest({-by-reference:R}, RELS_LIST, {-new:list of L}, RLIST_ALL_Y) -). [2]</span>
<span class="plain">To decide which list of Ks is list of (name of kind of value K) that/which/who</span>
<span class="plain">relate to (Y - L) by (R - relation of Ks to values of kind L)</span>
<span class="plain">(documented at ph_leftlookuplist):</span>
<span class="plain">(- RelationTest({-by-reference:R}, RELS_LOOKUP_ALL_X, {Y}, {-new:list of K}) -).</span>
<span class="plain">To decide which list of Ls is list of (name of kind of value L) to which/whom (X - K)</span>
<span class="plain">relates by (R - relation of values of kind K to Ls)</span>
<span class="plain">(documented at ph_rightlookuplist):</span>
<span class="plain">(- RelationTest({-by-reference:R}, RELS_LOOKUP_ALL_Y, {X}, {-new:list of L}) -). [1]</span>
<span class="plain">To decide which list of Ls is list of (name of kind of value L)</span>
<span class="plain">that/which/whom (X - K) relates to by (R - relation of values of kind K to Ls)</span>
<span class="plain">(documented at ph_rightlookuplist):</span>
<span class="plain">(- RelationTest({-by-reference:R}, RELS_LOOKUP_ALL_Y, {X}, {-new:list of L}) -). [2]</span>
<span class="plain">To decide whether (name of kind of value K) relates to (Y - L) by</span>
<span class="plain">(R - relation of Ks to values of kind L)</span>
<span class="plain">(documented at ph_ifright):</span>
<span class="plain">(- RelationTest({-by-reference:R}, RELS_LOOKUP_ANY, {Y}, RLANY_CAN_GET_X) -).</span>
<span class="plain">To decide whether (X - K) relates to (name of kind of value L) by</span>
<span class="plain">(R - relation of values of kind K to Ls)</span>
<span class="plain">(documented at ph_ifleft):</span>
<span class="plain">(- RelationTest({-by-reference:R}, RELS_LOOKUP_ANY, {X}, RLANY_CAN_GET_Y) -).</span>
<span class="plain">To decide which K is (name of kind of value K) that/which/who relates to</span>
<span class="plain">(Y - L) by (R - relation of Ks to values of kind L)</span>
<span class="plain">(documented at ph_leftlookup):</span>
<span class="plain">(- RelationTest({-by-reference:R}, RELS_LOOKUP_ANY, {Y}, RLANY_GET_X) -).</span>
<span class="plain">To decide which L is (name of kind of value L) to which/whom (X - K)</span>
<span class="plain">relates by (R - relation of values of kind K to Ls)</span>
<span class="plain">(documented at ph_rightlookup):</span>
<span class="plain">(- RelationTest({-by-reference:R}, RELS_LOOKUP_ANY, {X}, RLANY_GET_Y) -). [1]</span>
<span class="plain">To decide which L is (name of kind of value L) that/which/whom (X - K)</span>
<span class="plain">relates to by (R - relation of values of kind K to Ls)</span>
<span class="plain">(documented at ph_rightlookup):</span>
<span class="plain">(- RelationTest({-by-reference:R}, RELS_LOOKUP_ANY, {X}, RLANY_GET_Y) -). [2]</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP33"></a><b>&#167;33. </b>The standard map and reduce operations found in most functional programming
2019-03-17 14:40:57 +02:00
languages:
</p>
<pre class="display">
<span class="plain">Section SR5/2/20 - Values - Functional programming</span>
<span class="plain">To decide whether (val - K) matches (desc - description of values of kind K)</span>
<span class="plain">(documented at ph_valuematch):</span>
<span class="plain">(- {-primitive-definition:description-application} -).</span>
<span class="plain">To decide what K is (function - phrase nothing -&gt; value of kind K) applied</span>
<span class="plain">(documented at ph_applied0):</span>
<span class="plain">(- {-primitive-definition:function-application} -).</span>
<span class="plain">To decide what L is (function - phrase value of kind K -&gt; value of kind L)</span>
<span class="plain">applied to (input - K)</span>
<span class="plain">(documented at ph_applied1):</span>
<span class="plain">(- {-primitive-definition:function-application} -).</span>
<span class="plain">To decide what M is (function - phrase (value of kind K, value of kind L) -&gt; value of kind M)</span>
<span class="plain">applied to (input - K) and (second input - L)</span>
<span class="plain">(documented at ph_applied2):</span>
<span class="plain">(- {-primitive-definition:function-application} -).</span>
<span class="plain">To decide what N is (function - phrase (value of kind K, value of kind L, value of kind M) -&gt; value of kind N)</span>
<span class="plain">applied to (input - K) and (second input - L) and (third input - M)</span>
<span class="plain">(documented at ph_applied3):</span>
<span class="plain">(- {-primitive-definition:function-application} -).</span>
<span class="plain">To apply (function - phrase nothing -&gt; nothing)</span>
<span class="plain">(documented at ph_apply0):</span>
<span class="plain">(- {-primitive-definition:function-application}; -).</span>
<span class="plain">To apply (function - phrase value of kind K -&gt; nothing)</span>
<span class="plain">to (input - K)</span>
<span class="plain">(documented at ph_apply1):</span>
<span class="plain">(- {-primitive-definition:function-application}; -).</span>
<span class="plain">To apply (function - phrase (value of kind K, value of kind L) -&gt; nothing)</span>
<span class="plain">to (input - K) and (second input - L)</span>
<span class="plain">(documented at ph_apply2):</span>
<span class="plain">(- {-primitive-definition:function-application}; -).</span>
<span class="plain">To apply (function - phrase (value of kind K, value of kind L, value of kind M) -&gt; nothing)</span>
<span class="plain">to (input - K) and (second input - L) and (third input - M)</span>
<span class="plain">(documented at ph_apply3):</span>
<span class="plain">(- {-primitive-definition:function-application}; -).</span>
<span class="plain">To decide what list of L is (function - phrase K -&gt; value of kind L) applied to (original list - list of values of kind K)</span>
<span class="plain">(documented at ph_appliedlist):</span>
<span class="plain">let the result be a list of Ls;</span>
<span class="plain">repeat with item running through the original list:</span>
<span class="plain">let the mapped item be the function applied to the item;</span>
<span class="plain">add the mapped item to the result;</span>
<span class="plain">decide on the result.</span>
<span class="plain">To decide what K is the (function - phrase (K, K) -&gt; K) reduction of (original list - list of values of kind K)</span>
<span class="plain">(documented at ph_reduction):</span>
<span class="plain">let the total be a K;</span>
<span class="plain">let the count be 0;</span>
<span class="plain">repeat with item running through the original list:</span>
<span class="plain">increase the count by 1;</span>
<span class="plain">if the count is 1, now the total is the item;</span>
<span class="plain">otherwise now the total is the function applied to the total and the item;</span>
<span class="plain">decide on the total.</span>
<span class="plain">To decide what list of K is the filter to (criterion - description of Ks) of</span>
<span class="plain">(full list - list of values of kind K)</span>
<span class="plain">(documented at ph_filter):</span>
<span class="plain">let the filtered list be a list of K;</span>
<span class="plain">repeat with item running through the full list:</span>
<span class="plain">if the item matches the criterion:</span>
<span class="plain">add the item to the filtered list;</span>
<span class="plain">decide on the filtered list.</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP34"></a><b>&#167;34. Using external resources. </b>The following all refer to "FileIO.i6t" and work only on Glulx.
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/2/21 - Values - Files (for Glulx external files language element only)</span>
<span class="plain">To read (filename - external file) into (T - table name)</span>
<span class="plain">(documented at ph_readtable):</span>
<span class="plain">(- FileIO_GetTable({filename}, {T}); -).</span>
<span class="plain">To write (filename - external file) from (T - table name)</span>
<span class="plain">(documented at ph_writetable):</span>
<span class="plain">(- FileIO_PutTable({filename}, {T}); -).</span>
<span class="plain">To decide if (filename - external file) exists</span>
<span class="plain">(documented at ph_fileexists):</span>
<span class="plain">(- (FileIO_Exists({filename}, false)) -).</span>
<span class="plain">To decide if ready to read (filename - external file)</span>
<span class="plain">(documented at ph_fileready):</span>
<span class="plain">(- (FileIO_Ready({filename}, false)) -).</span>
<span class="plain">To mark (filename - external file) as ready to read</span>
<span class="plain">(documented at ph_markfileready):</span>
<span class="plain">(- FileIO_MarkReady({filename}, true); -).</span>
<span class="plain">To mark (filename - external file) as not ready to read</span>
<span class="plain">(documented at ph_markfilenotready):</span>
<span class="plain">(- FileIO_MarkReady({filename}, false); -).</span>
<span class="plain">To write (T - text) to (FN - external file)</span>
<span class="plain">(documented at ph_writetext):</span>
<span class="plain">(- FileIO_PutContents({FN}, {T}, false); -).</span>
<span class="plain">To append (T - text) to (FN - external file)</span>
<span class="plain">(documented at ph_appendtext):</span>
<span class="plain">(- FileIO_PutContents({FN}, {T}, true); -).</span>
<span class="plain">To say text of (FN - external file)</span>
<span class="plain">(documented at ph_saytext):</span>
<span class="plain">(- FileIO_PrintContents({FN}); say__p = 1; -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP35"></a><b>&#167;35. </b>Figures and sound effects.
2019-03-17 14:40:57 +02:00
Ditto, but for "Figures.i6t".
</p>
<pre class="display">
<span class="plain">Section SR5/2/22 - Values - Figures (for figures language element only)</span>
<span class="plain">To display (F - figure name), one time only</span>
<span class="plain">(documented at ph_displayfigure):</span>
<span class="plain">(- DisplayFigure(ResourceIDsOfFigures--&gt;{F}, {phrase options}); -).</span>
<span class="plain">To decide which number is the Glulx resource ID of (F - figure name)</span>
<span class="plain">(documented at ph_figureid):</span>
<span class="plain">(- ResourceIDsOfFigures--&gt;{F} -).</span>
<span class="plain">Section SR5/2/23 - Values - Sound effects (for sounds language element only)</span>
<span class="plain">To play (SFX - sound name), one time only</span>
<span class="plain">(documented at ph_playsf):</span>
<span class="plain">(- PlaySound(ResourceIDsOfSounds--&gt;{SFX}, {phrase options}); -).</span>
<span class="plain">To decide which number is the Glulx resource ID of (SFX - sound name)</span>
<span class="plain">(documented at ph_soundid):</span>
<span class="plain">(- ResourceIDsOfSounds--&gt;{SFX} -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP36"></a><b>&#167;36. Control phrases. </b>While "unless" is supposed to be exactly like "if" but with the reversed
2019-03-17 14:40:57 +02:00
sense of the condition, that isn't quite true. For example, there is no
"unless ... then ...": logical it might be, English it is not.
</p>
<pre class="display">
<span class="plain">Section SR5/3/1 - Control phrases - If and unless</span>
<span class="plain">To if (c - condition) begin -- end conditional</span>
<span class="plain">(documented at ph_if):</span>
<span class="plain">(- {c} -).</span>
<span class="plain">To unless (c - condition) begin -- end conditional</span>
<span class="plain">(documented at ph_unless):</span>
<span class="plain">(- (~~{c}) -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP37"></a><b>&#167;37. </b>The switch form of "if" is subtly different, and here again "unless" is
2019-03-17 14:40:57 +02:00
not allowed in its place.
</p>
<p class="inwebparagraph">The begin and end markers here are in a sense bogus, in that the end
user isn't supposed to type them: they are inserted automatically in
the sentence subtree maker, which converts indentation into block
structure.
</p>
<pre class="display">
<span class="plain">To if (V - value) is begin -- end conditional</span>
<span class="plain">(documented at ph_switch):</span>
<span class="plain">(- -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP38"></a><b>&#167;38. </b>After all that, the while loop is simplicity itself. Perhaps the presence
2019-03-17 14:40:57 +02:00
of "unless" for "if" argues for a similarly negated form, "until" for
"while", but users haven't yet petitioned for this.
</p>
<pre class="display">
<span class="plain">Section SR5/3/2 - Control phrases - While</span>
<span class="plain">To while (c - condition) begin -- end loop</span>
<span class="plain">(documented at ph_while):</span>
<span class="plain">(- while {c} -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP39"></a><b>&#167;39. </b>The repeat loop looks like a single construction, but isn't, because the
2019-03-17 14:40:57 +02:00
range can be given in four fundamentally different ways (and the loop variable
then has a different kind of value accordingly). First, the equivalents of
BASIC's <code class="display"><span class="extract">for</span></code> loop and of Inform 6's <code class="display"><span class="extract">objectloop</span></code>, respectively:
</p>
<pre class="display">
<span class="plain">Section SR5/3/3 - Control phrases - Repeat</span>
<span class="plain">To repeat with (loopvar - nonexisting K variable)</span>
<span class="plain">running from (v - arithmetic value of kind K) to (w - K) begin -- end loop</span>
<span class="plain">(documented at ph_repeat):</span>
<span class="plain">(- for ({loopvar}={v}: {loopvar}&lt;={w}: {loopvar}++) -).</span>
<span class="plain">To repeat with (loopvar - nonexisting K variable)</span>
<span class="plain">running from (v - enumerated value of kind K) to (w - K) begin -- end loop</span>
<span class="plain">(documented at ph_repeat):</span>
<span class="plain">(- for ({loopvar}={v}: {loopvar}&lt;={w}: {loopvar}++) -).</span>
<span class="plain">To repeat with (loopvar - nonexisting K variable)</span>
<span class="plain">running through (OS - description of values of kind K) begin -- end loop</span>
<span class="plain">(documented at ph_runthrough):</span>
<span class="plain">(- {-primitive-definition:repeat-through} -).</span>
<span class="plain">To repeat with (loopvar - nonexisting object variable)</span>
<span class="plain">running through (L - list of values) begin -- end loop</span>
<span class="plain">(documented at ph_repeatlist):</span>
<span class="plain">(- {-primitive-definition:repeat-through-list} -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP40"></a><b>&#167;40. </b>The following are all repeats where the range is the set of rows of a table,
2019-03-17 14:40:57 +02:00
taken in some order, and the repeat variable &mdash; though it does exist &mdash; is
never specified since the relevant row is instead the one selected during
each iteration of the loop.
</p>
<pre class="display">
<span class="plain">To repeat through (T - table name) begin -- end loop</span>
<span class="plain">(documented at ph_repeattable): (-</span>
<span class="plain">@push {-my:ct_0}; @push {-my:ct_1};</span>
<span class="plain">for ({-my:1}={T}, {-my:2}=1, ct_0={-my:1}, ct_1={-my:2}:</span>
<span class="plain">{-my:2}&lt;=TableRows({-my:1}):</span>
<span class="plain">{-my:2}++, ct_0={-my:1}, ct_1={-my:2})</span>
<span class="plain">if (TableRowIsBlank(ct_0, ct_1)==false)</span>
<span class="plain">{-block}</span>
<span class="plain">@pull {-my:ct_1}; @pull {-my:ct_0};</span>
<span class="plain">-).</span>
<span class="plain">To repeat through (T - table name) in reverse order begin -- end loop</span>
<span class="plain">(documented at ph_repeattablereverse): (-</span>
<span class="plain">@push {-my:ct_0}; @push {-my:ct_1};</span>
<span class="plain">for ({-my:1}={T}, {-my:2}=TableRows({-my:1}), ct_0={-my:1}, ct_1={-my:2}:</span>
<span class="plain">{-my:2}&gt;=1:</span>
<span class="plain">{-my:2}--, ct_0={-my:1}, ct_1={-my:2})</span>
<span class="plain">if (TableRowIsBlank(ct_0, ct_1)==false)</span>
<span class="plain">{-block}</span>
<span class="plain">@pull {-my:ct_1}; @pull {-my:ct_0};</span>
<span class="plain">-).</span>
<span class="plain">To repeat through (T - table name) in (TC - table column) order begin -- end loop</span>
<span class="plain">(documented at ph_repeattablecol): (-</span>
<span class="plain">@push {-my:ct_0}; @push {-my:ct_1};</span>
<span class="plain">for ({-my:1}={T}, {-my:2}=TableNextRow({-my:1}, {TC}, 0, 1), ct_0={-my:1}, ct_1={-my:2}:</span>
<span class="plain">{-my:2}~=0:</span>
<span class="plain">{-my:2}=TableNextRow({-my:1}, {TC}, {-my:2}, 1), ct_0={-my:1}, ct_1={-my:2})</span>
<span class="plain">{-block}</span>
<span class="plain">@pull {-my:ct_1}; @pull {-my:ct_0};</span>
<span class="plain">-).</span>
<span class="plain">To repeat through (T - table name) in reverse (TC - table column) order begin -- end loop</span>
<span class="plain">(documented at ph_repeattablecolreverse): (-</span>
<span class="plain">@push {-my:ct_0}; @push {-my:ct_1};</span>
<span class="plain">for ({-my:1}={T}, {-my:2}=TableNextRow({-my:1}, {TC}, 0, -1), ct_0={-my:1}, ct_1={-my:2}:</span>
<span class="plain">{-my:2}~=0:</span>
<span class="plain">{-my:2}=TableNextRow({-my:1}, {TC}, {-my:2}, -1), ct_0={-my:1}, ct_1={-my:2})</span>
<span class="plain">{-block}</span>
<span class="plain">@pull {-my:ct_1}; @pull {-my:ct_0};</span>
<span class="plain">-).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP41"></a><b>&#167;41. </b>The equivalent of <code class="display"><span class="extract">break</span></code> or <code class="display"><span class="extract">continue</span></code> in C or I6, or of <code class="display"><span class="extract">last</span></code> or <code class="display"><span class="extract">next</span></code>
2019-03-17 14:40:57 +02:00
in Perl. Here "in loop" means "in any of the forms of while or repeat".
</p>
<pre class="display">
<span class="plain">Section SR5/3/6 - Control phrases - Changing the flow of loops</span>
<span class="plain">To break -- in loop</span>
<span class="plain">(documented at ph_break):</span>
<span class="plain">(- {-primitive-definition:break} -).</span>
<span class="plain">To next -- in loop</span>
<span class="plain">(documented at ph_next):</span>
<span class="plain">(- continue; -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP42"></a><b>&#167;42. </b>The following certainly aren't loops and aren't quite conditionals either,
2019-03-17 14:40:57 +02:00
but they reflect the use of rules within rulebooks as being a form of
control structure, and they have to be indexed somewhere.
</p>
<p class="inwebparagraph">The antique forms "yes" and "no" are now somewhat to be regretted, with
"decide yes" and "decide no" being clearer ways to write the same thing.
But we seem to be stuck with them.
</p>
<pre class="display">
<span class="plain">Section SR5/3/7 - Control phrases - Deciding outcomes</span>
<span class="plain">To yes</span>
<span class="plain">(documented at ph_yes):</span>
<span class="plain">(- rtrue; -) - in to decide if only.</span>
<span class="plain">To decide yes</span>
<span class="plain">(documented at ph_yes):</span>
<span class="plain">(- rtrue; -) - in to decide if only.</span>
<span class="plain">To no</span>
<span class="plain">(documented at ph_no):</span>
<span class="plain">(- rfalse; -) - in to decide if only.</span>
<span class="plain">To decide no</span>
<span class="plain">(documented at ph_no):</span>
<span class="plain">(- rfalse; -) - in to decide if only.</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP43"></a><b>&#167;43. </b>Note that returning a value has to invoke the type-checker to ensure that
2019-03-17 14:40:57 +02:00
the return value matches the kind of value expected. This certainly rejects
the phrase if it's used in a definition which isn't meant to be deciding
a value at all, so an "in... only" clause is not needed.
</p>
<pre class="display">
<span class="plain">To decide on (something - value)</span>
<span class="plain">(documented at ph_decideon):</span>
<span class="plain">(- return {-return-value:something}; -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP44"></a><b>&#167;44. Actions, activities and rules. </b>We begin with the firing off of new actions. The current action runs silently
2019-03-17 14:40:57 +02:00
if the I6 global variable <code class="display"><span class="extract">keep_silent</span></code> is set, so the result of the
definitions below is that one can go into silence mode, using "try silently",
but not climb out of it again. This is done because many actions try other
actions as part of their normal workings: if we want action X to be tried
silently, then any action X itself tries should also be tried silently.
</p>
<pre class="display">
<span class="plain">Section SR5/4/1 - Actions, activities and rules - Trying actions (for interactive fiction language element only)</span>
<span class="plain">To try (S - action)</span>
<span class="plain">(documented at ph_try):</span>
<span class="plain">(- {-try-action:S} -).</span>
<span class="plain">To silently try (S - action)</span>
<span class="plain">(documented at ph_trysilently):</span>
<span class="plain">(- {-try-action-silently:S} -).</span>
<span class="plain">To try silently (S - action)</span>
<span class="plain">(documented at ph_trysilently):</span>
<span class="plain">(- {-try-action-silently:S} -).</span>
<span class="plain">To decide whether the action is not silent:</span>
<span class="plain">(- (keep_silent == false) -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP45"></a><b>&#167;45. </b>The requirements of the current action can be tested. The following
2019-03-17 14:40:57 +02:00
may be reimplemented using a verb "to require" at some future point.
</p>
<pre class="display">
<span class="plain">Section SR5/4/2 - Actions, activities and rules - Action requirements (for interactive fiction language element only)</span>
<span class="plain">To decide whether the action requires a touchable noun</span>
<span class="plain">(documented at ph_requirestouch):</span>
<span class="plain">(- (NeedToTouchNoun()) -).</span>
<span class="plain">To decide whether the action requires a touchable second noun</span>
<span class="plain">(documented at ph_requirestouch2):</span>
<span class="plain">(- (NeedToTouchSecondNoun()) -).</span>
<span class="plain">To decide whether the action requires a carried noun</span>
<span class="plain">(documented at ph_requirescarried):</span>
<span class="plain">(- (NeedToCarryNoun()) -).</span>
<span class="plain">To decide whether the action requires a carried second noun</span>
<span class="plain">(documented at ph_requirescarried2):</span>
<span class="plain">(- (NeedToCarrySecondNoun()) -).</span>
<span class="plain">To decide whether the action requires light</span>
<span class="plain">(documented at ph_requireslight):</span>
<span class="plain">(- (NeedLightForAction()) -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP46"></a><b>&#167;46. </b>Within the rulebooks to do with an action, returning <code class="display"><span class="extract">true</span></code> from a rule
2019-03-17 14:40:57 +02:00
is sufficient to stop the rulebook early: there is no need to specify
success or failure because that is determined by the rulebook itself. (For
instance, if the check taking rules stop for any reason, the action failed;
if the after rules stop, it succeeded.) In some rulebooks, notably "instead"
and "after", the default is to stop, so that execution reaching the end of
the I6 routine for a rule will run into an <code class="display"><span class="extract">rtrue</span></code>. "Continue the action"
prevents this.
</p>
<pre class="display">
<span class="plain">Section SR5/4/3 - Actions, activities and rules - Stop or continue (for interactive fiction language element only)</span>
<span class="plain">To stop the action</span>
<span class="plain">(documented at ph_stopaction):</span>
<span class="plain">(- rtrue; -) - in to only.</span>
<span class="plain">To continue the action</span>
<span class="plain">(documented at ph_continueaction):</span>
<span class="plain">(- rfalse; -) - in to only.</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP47"></a><b>&#167;47. </b></p>
2019-03-17 14:40:57 +02:00
<pre class="display">
<span class="plain">Section SR5/4/4 - Actions, activities and rules - Actions as values (for interactive fiction language element only)</span>
<span class="plain">To decide what action is the current action</span>
<span class="plain">(documented at ph_currentaction):</span>
<span class="plain">(- STORED_ACTION_TY_Current({-new:action}) -).</span>
<span class="plain">To decide what action is the action of (A - action)</span>
<span class="plain">(documented at ph_actionof):</span>
<span class="plain">(- {A} -).</span>
<span class="plain">To decide if (act - a action) involves (X - an object)</span>
<span class="plain">(documented at ph_involves):</span>
<span class="plain">(- (STORED_ACTION_TY_Involves({-by-reference:act}, {X})) -).</span>
<span class="plain">To decide what action name is the action name part of (act - a action)</span>
<span class="plain">(documented at ph_actionpart):</span>
<span class="plain">(- (STORED_ACTION_TY_Part({-by-reference:act}, STORA_ACTION_F)) -).</span>
<span class="plain">To decide what object is the noun part of (act - a action)</span>
<span class="plain">(documented at ph_nounpart):</span>
<span class="plain">(- (STORED_ACTION_TY_Part({-by-reference:act}, STORA_NOUN_F)) -).</span>
<span class="plain">To decide what object is the second noun part of (act - a action)</span>
<span class="plain">(documented at ph_secondpart):</span>
<span class="plain">(- (STORED_ACTION_TY_Part({-by-reference:act}, STORA_SECOND_F)) -).</span>
<span class="plain">To decide what object is the actor part of (act - a action)</span>
<span class="plain">(documented at ph_actorpart):</span>
<span class="plain">(- (STORED_ACTION_TY_Part({-by-reference:act}, STORA_ACTOR_F)) -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP48"></a><b>&#167;48. </b>Firing off activities:
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/4/5 - Actions, activities and rules - Carrying out activities</span>
<span class="plain">To carry out the (A - activity on nothing) activity</span>
<span class="plain">(documented at ph_carryout):</span>
<span class="plain">(- CarryOutActivity({A}); -).</span>
<span class="plain">To carry out the (A - activity on value of kind K) activity with (val - K)</span>
<span class="plain">(documented at ph_carryoutwith):</span>
<span class="plain">(- CarryOutActivity({A}, {val}); -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP49"></a><b>&#167;49. </b>This is analogous to "continue the action":
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">To continue the activity</span>
<span class="plain">(documented at ph_continueactivity):</span>
<span class="plain">(- rfalse; -) - in to only.</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP50"></a><b>&#167;50. </b>Advanced activity phrases: for setting up one's own activities structured
2019-03-17 14:40:57 +02:00
around I7 source text. People tend not to use this much, and perhaps that's
a good thing, but it does open up possibilities, and it's good for
retro-fitting onto extensions to make the more customisable.
</p>
<pre class="display">
<span class="plain">Section SR5/4/6 - Actions, activities and rules - Advanced activities</span>
<span class="plain">To begin the (A - activity on nothing) activity</span>
<span class="plain">(documented at ph_beginactivity):</span>
<span class="plain">(- BeginActivity({A}); -).</span>
<span class="plain">To begin the (A - activity on value of kind K) activity with (val - K)</span>
<span class="plain">(documented at ph_beginactivitywith):</span>
<span class="plain">(- BeginActivity({A}, {val}); -).</span>
<span class="plain">To decide whether handling (A - activity) activity</span>
<span class="plain">(documented at ph_handlingactivity):</span>
<span class="plain">(- (~~(ForActivity({A}))) -).</span>
<span class="plain">To decide whether handling (A - activity on value of kind K) activity with (val - K)</span>
<span class="plain">(documented at ph_handlingactivitywith):</span>
<span class="plain">(- (~~(ForActivity({A}, {val}))) -).</span>
<span class="plain">To end the (A - activity on nothing) activity</span>
<span class="plain">(documented at ph_endactivity):</span>
<span class="plain">(- EndActivity({A}); -).</span>
<span class="plain">To end the (A - activity on value of kind K) activity with (val - K)</span>
<span class="plain">(documented at ph_endactivitywith):</span>
<span class="plain">(- EndActivity({A}, {val}); -).</span>
<span class="plain">To abandon the (A - activity on nothing) activity</span>
<span class="plain">(documented at ph_abandonactivity):</span>
<span class="plain">(- AbandonActivity({A}); -).</span>
<span class="plain">To abandon the (A - activity on value of kind K) activity with (val - K)</span>
<span class="plain">(documented at ph_abandonactivitywith):</span>
<span class="plain">(- AbandonActivity({A}, {val}); -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP51"></a><b>&#167;51. Rules. </b>Four different ways to invoke a rule or rulebook:
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/4/7 - Actions, activities and rules - Following rules</span>
<span class="plain">To follow (RL - a rule)</span>
<span class="plain">(documented at ph_follow):</span>
<span class="plain">(- FollowRulebook({RL}); -).</span>
<span class="plain">To follow (RL - value of kind K based rule producing a value) for (V - K)</span>
<span class="plain">(documented at ph_followfor):</span>
<span class="plain">(- FollowRulebook({RL}, {V}, true); -).</span>
<span class="plain">To follow (RL - a nothing based rule)</span>
<span class="plain">(documented at ph_follow):</span>
<span class="plain">(- FollowRulebook({RL}); -).</span>
<span class="plain">To decide what K is the (name of kind K) produced by (RL - rule producing a value of kind K)</span>
<span class="plain">(documented at ph_producedby):</span>
<span class="plain">(- ResultOfRule({RL}, 0, true, {-strong-kind:K}) -).</span>
<span class="plain">To decide what L is the (name of kind L) produced by (RL - value of kind K based rule</span>
<span class="plain">producing a value of kind L) for (V - K)</span>
<span class="plain">(documented at ph_producedbyfor):</span>
<span class="plain">(- ResultOfRule({RL}, {V}, true, {-strong-kind:L}) -).</span>
<span class="plain">To decide what K is the (name of kind K) produced by (RL - nothing based rule producing a value of kind K)</span>
<span class="plain">(documented at ph_producedby):</span>
<span class="plain">(- ResultOfRule({RL}, 0, true, {-strong-kind:K}) -).</span>
<span class="plain">To abide by (RL - a rule)</span>
<span class="plain">(documented at ph_abide):</span>
<span class="plain">(- if (FollowRulebook({RL})) rtrue; -) - in to only.</span>
<span class="plain">To abide by (RL - value of kind K based rule producing a value) for (V - K)</span>
<span class="plain">(documented at ph_abidefor):</span>
<span class="plain">(- if (FollowRulebook({RL}, {V}, true)) rtrue; -) - in to only.</span>
<span class="plain">To abide by (RL - a nothing based rule)</span>
<span class="plain">(documented at ph_abide):</span>
<span class="plain">(- if (FollowRulebook({RL})) rtrue; -) - in to only.</span>
<span class="plain">To anonymously abide by (RL - a rule)</span>
<span class="plain">(documented at ph_abideanon):</span>
<span class="plain">(- if (temporary_value = FollowRulebook({RL})) {</span>
<span class="plain">if (RulebookSucceeded()) ActRulebookSucceeds(temporary_value);</span>
<span class="plain">else ActRulebookFails(temporary_value);</span>
<span class="plain">return 2;</span>
<span class="plain">} -) - in to only.</span>
<span class="plain">To anonymously abide by (RL - value of kind K based rule producing a value) for (V - K)</span>
<span class="plain">(documented at ph_abideanon):</span>
<span class="plain">(- if (temporary_value = FollowRulebook({RL}, {V}, true)) {</span>
<span class="plain">if (RulebookSucceeded()) ActRulebookSucceeds(temporary_value);</span>
<span class="plain">else ActRulebookFails(temporary_value);</span>
<span class="plain">return 2;</span>
<span class="plain">} -) - in to only.</span>
<span class="plain">To anonymously abide by (RL - a nothing based rule)</span>
<span class="plain">(documented at ph_abideanon):</span>
<span class="plain">(- if (temporary_value = FollowRulebook({RL})) {</span>
<span class="plain">if (RulebookSucceeded()) ActRulebookSucceeds(temporary_value);</span>
<span class="plain">else ActRulebookFails(temporary_value);</span>
<span class="plain">return 2;</span>
<span class="plain">} -) - in to only.</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP52"></a><b>&#167;52. </b>Rules return <code class="display"><span class="extract">true</span></code> to indicate a decision, which could be either a success
2019-03-17 14:40:57 +02:00
or a failure, and optionally may also return a value. If they return <code class="display"><span class="extract">false</span></code>,
there's no decision.
</p>
<pre class="display">
<span class="plain">Section SR5/4/8 - Actions, activities and rules - Success and failure</span>
<span class="plain">To make no decision</span>
<span class="plain">(documented at ph_nodecision): (- rfalse; -) - in to only.</span>
<span class="plain">To rule succeeds</span>
<span class="plain">(documented at ph_succeeds):</span>
<span class="plain">(- RulebookSucceeds(); rtrue; -) - in to only.</span>
<span class="plain">To rule fails</span>
<span class="plain">(documented at ph_fails):</span>
<span class="plain">(- RulebookFails(); rtrue; -) - in to only.</span>
<span class="plain">To rule succeeds with result (val - a value)</span>
<span class="plain">(documented at ph_succeedswith):</span>
<span class="plain">(- RulebookSucceeds({-weak-kind:rule-return-kind},{-return-value-from-rule:val}); rtrue; -) - in to only.</span>
<span class="plain">To decide if rule succeeded</span>
<span class="plain">(documented at ph_succeeded):</span>
<span class="plain">(- (RulebookSucceeded()) -).</span>
<span class="plain">To decide if rule failed</span>
<span class="plain">(documented at ph_failed):</span>
<span class="plain">(- (RulebookFailed()) -).</span>
<span class="plain">To decide which rulebook outcome is the outcome of the rulebook</span>
<span class="plain">(documented at ph_rulebookoutcome):</span>
<span class="plain">(- (ResultOfRule()) -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP53"></a><b>&#167;53. The model world. </b>Phrase definitions with wordings like "the story has ended" are a
2019-03-17 14:40:57 +02:00
necessary evil. The "has" here is parsed literally, not as the present
tense of "to have", so inflected forms like "the story had ended" are
not available: nor is there any value "the story" for the subject noun
phrase to hold... and so on. Ideally, we would word all conditional phrases
so as to avoid the verbs, but natural language just doesn't work that way.
</p>
<pre class="display">
<span class="plain">Section SR5/5/1 - Model world - Ending the story (for interactive fiction language element only)</span>
<span class="plain">To end the story</span>
<span class="plain">(documented at ph_end):</span>
<span class="plain">(- deadflag=3; story_complete=false; -).</span>
<span class="plain">To end the story finally</span>
<span class="plain">(documented at ph_endfinally):</span>
<span class="plain">(- deadflag=3; story_complete=true; -).</span>
<span class="plain">To end the story saying (finale - text)</span>
<span class="plain">(documented at ph_endsaying):</span>
<span class="plain">(- deadflag={-by-reference:finale}; story_complete=false; -).</span>
<span class="plain">To end the story finally saying (finale - text)</span>
<span class="plain">(documented at ph_endfinallysaying):</span>
<span class="plain">(- deadflag={-by-reference:finale}; story_complete=true; -).</span>
<span class="plain">To decide whether the story has ended</span>
<span class="plain">(documented at ph_ended):</span>
<span class="plain">(- (deadflag~=0) -).</span>
<span class="plain">To decide whether the story has ended finally</span>
<span class="plain">(documented at ph_finallyended):</span>
<span class="plain">(- (story_complete) -).</span>
<span class="plain">To decide whether the story has not ended</span>
<span class="plain">(documented at ph_notended):</span>
<span class="plain">(- (deadflag==0) -).</span>
<span class="plain">To decide whether the story has not ended finally</span>
<span class="plain">(documented at ph_notfinallyended):</span>
<span class="plain">(- (story_complete==false) -).</span>
<span class="plain">To resume the story</span>
<span class="plain">(documented at ph_resume):</span>
<span class="plain">(- resurrect_please = true; -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP54"></a><b>&#167;54. </b>Times of day.
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/5/2 - Model world - Times of day (for interactive fiction language element only)</span>
<span class="plain">To decide which number is the minutes part of (t - time)</span>
<span class="plain">(documented at ph_minspart):</span>
<span class="plain">(- ({t}%ONE_HOUR) -).</span>
<span class="plain">To decide which number is the hours part of (t - time)</span>
<span class="plain">(documented at ph_hourspart):</span>
<span class="plain">(- ({t}/ONE_HOUR) -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP55"></a><b>&#167;55. </b>Comparing times of day is inherently odd, because the day is
2019-03-17 14:40:57 +02:00
circular. Every 2 PM comes after a 1 PM, but it also comes before
another 1 PM. Where do we draw the meridian on this circle? The legal
day divides at midnight but for other purposes (daylight savings time,
for instance) society often chooses 2 AM as the boundary. Inform uses
4 AM instead as the least probable time through which play continues.
(Modulo a 24-hour clock, adding 20 hours is equivalent to subtracting
4 AM from the current time: hence the use of <code class="display"><span class="extract">20*ONE_HOUR</span></code> below.)
Thus 3:59 AM is after 4:00 AM, the former being at the very end of a
day, the latter at the very beginning.
</p>
<pre class="display">
<span class="plain">To decide if (t - time) is before (t2 - time)</span>
<span class="plain">(documented at ph_timebefore):</span>
<span class="plain">(- ((({t}+20*ONE_HOUR)%(TWENTY_FOUR_HOURS))&lt;(({t2}+20*ONE_HOUR)%(TWENTY_FOUR_HOURS))) -).</span>
<span class="plain">To decide if (t - time) is after (t2 - time)</span>
<span class="plain">(documented at ph_timeafter):</span>
<span class="plain">(- ((({t}+20*ONE_HOUR)%(TWENTY_FOUR_HOURS))&gt;(({t2}+20*ONE_HOUR)%(TWENTY_FOUR_HOURS))) -).</span>
<span class="plain">To decide which time is (t - time) before (t2 - time)</span>
<span class="plain">(documented at ph_shiftbefore):</span>
<span class="plain">(- (({t2}-{t}+TWENTY_FOUR_HOURS)%(TWENTY_FOUR_HOURS)) -).</span>
<span class="plain">To decide which time is (t - time) after (t2 - time)</span>
<span class="plain">(documented at ph_shiftafter):</span>
<span class="plain">(- (({t2}+{t}+TWENTY_FOUR_HOURS)%(TWENTY_FOUR_HOURS)) -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP56"></a><b>&#167;56. </b>Durations are in effect casts from "number" to "time".
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/5/3 - Model world - Durations (for interactive fiction language element only)</span>
<span class="plain">To decide which time is (n - number) minutes</span>
<span class="plain">(documented at ph_durationmins):</span>
<span class="plain">(- (({n})%(TWENTY_FOUR_HOURS)) -).</span>
<span class="plain">To decide which time is (n - number) hours</span>
<span class="plain">(documented at ph_durationhours):</span>
<span class="plain">(- (({n}*ONE_HOUR)%(TWENTY_FOUR_HOURS)) -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP57"></a><b>&#167;57. </b>Timed events.
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/5/4 - Model world - Timed events (for interactive fiction language element only)</span>
<span class="plain">To (R - rule) in (t - number) turn/turns from now</span>
<span class="plain">(documented at ph_turnsfromnow):</span>
<span class="plain">(- SetTimedEvent({-mark-event-used:R}, {t}+1, 0); -).</span>
<span class="plain">To (R - rule) at (t - time)</span>
<span class="plain">(documented at ph_attime):</span>
<span class="plain">(- SetTimedEvent({-mark-event-used:R}, {t}, 1); -).</span>
<span class="plain">To (R - rule) in (t - time) from now</span>
<span class="plain">(documented at ph_timefromnow):</span>
<span class="plain">(- SetTimedEvent({-mark-event-used:R}, (the_time+{t})%(TWENTY_FOUR_HOURS), 1); -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP58"></a><b>&#167;58. </b>Scenes.
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/5/5 - Model world - Scenes (for interactive fiction language element only)</span>
<span class="plain">To decide if (sc - scene) has happened</span>
<span class="plain">(documented at ph_hashappened):</span>
<span class="plain">(- (scene_endings--&gt;({sc}-1)) -).</span>
<span class="plain">To decide if (sc - scene) has not happened</span>
<span class="plain">(documented at ph_hasnothappened):</span>
<span class="plain">(- (scene_endings--&gt;({sc}-1) == 0) -).</span>
<span class="plain">To decide if (sc - scene) has ended</span>
<span class="plain">(documented at ph_hasended):</span>
<span class="plain">(- (scene_endings--&gt;({sc}-1) &gt; 1) -).</span>
<span class="plain">To decide if (sc - scene) has not ended</span>
<span class="plain">(documented at ph_hasnotended):</span>
<span class="plain">(- (scene_endings--&gt;({sc}-1) &lt;= 1) -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP59"></a><b>&#167;59. </b>Timing of scenes.
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/5/6 - Model world - Timing of scenes (for interactive fiction language element only)</span>
<span class="plain">To decide which time is the time since (sc - scene) began</span>
<span class="plain">(documented at ph_scenetimesincebegan):</span>
<span class="plain">(- (SceneUtility({sc}, 1)) -).</span>
<span class="plain">To decide which time is the time when (sc - scene) began</span>
<span class="plain">(documented at ph_scenetimewhenbegan):</span>
<span class="plain">(- (SceneUtility({sc}, 2)) -).</span>
<span class="plain">To decide which time is the time since (sc - scene) ended</span>
<span class="plain">(documented at ph_scenetimesinceended):</span>
<span class="plain">(- (SceneUtility({sc}, 3)) -).</span>
<span class="plain">To decide which time is the time when (sc - scene) ended</span>
<span class="plain">(documented at ph_scenetimewhenended):</span>
<span class="plain">(- (SceneUtility({sc}, 4)) -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP60"></a><b>&#167;60. </b>Player's identity and location.
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/5/7 - Model world - Player's identity and location (for interactive fiction language element only)</span>
<span class="plain">To decide whether in darkness</span>
<span class="plain">(documented at ph_indarkness):</span>
<span class="plain">(- (location==thedark) -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP61"></a><b>&#167;61. </b>Moving and removing things.
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/5/8 - Model world - Moving and removing things (for interactive fiction language element only)</span>
<span class="plain">To move (something - object) to (something else - object),</span>
<span class="plain">without printing a room description</span>
<span class="plain">or printing an abbreviated room description</span>
<span class="plain">(documented at ph_move):</span>
<span class="plain">(- MoveObject({something}, {something else}, {phrase options}, false); -).</span>
<span class="plain">To remove (something - object) from play</span>
<span class="plain">(deprecated)</span>
<span class="plain">(documented at ph_remove):</span>
<span class="plain">(- RemoveFromPlay({something}); -).</span>
<span class="plain">To move (O - object) backdrop to all (D - description of objects)</span>
<span class="plain">(documented at ph_movebackdrop):</span>
<span class="plain">(- MoveBackdrop({O}, {D}); -).</span>
<span class="plain">To update backdrop positions</span>
<span class="plain">(documented at ph_updatebackdrop):</span>
<span class="plain">(- MoveFloatingObjects(); -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP62"></a><b>&#167;62. </b>The map.
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/5/9 - Model world - The map (for interactive fiction language element only)</span>
<span class="plain">To decide which room is location of (O - object)</span>
<span class="plain">(documented at ph_locationof):</span>
<span class="plain">(- LocationOf({O}) -).</span>
<span class="plain">To decide which room is room (D - direction) from/of (R1 - room)</span>
<span class="plain">(documented at ph_roomdirof):</span>
<span class="plain">(- MapConnection({R1},{D}) -).</span>
<span class="plain">To decide which door is door (D - direction) from/of (R1 - room)</span>
<span class="plain">(documented at ph_doordirof):</span>
<span class="plain">(- DoorFrom({R1},{D}) -).</span>
<span class="plain">To decide which object is the other side of (D - door) from (R1 - room)</span>
<span class="plain">(documented at ph_othersideof):</span>
<span class="plain">(- OtherSideOfDoor({D},{R1}) -).</span>
<span class="plain">To decide which object is the direction of (D - door) from (R1 - room)</span>
<span class="plain">(documented at ph_directionofdoor):</span>
<span class="plain">(- DirectionDoorLeadsIn({D},{R1}) -).</span>
<span class="plain">To decide which object is room-or-door (D - direction) from/of (R1 - room)</span>
<span class="plain">(documented at ph_roomordoor):</span>
<span class="plain">(- RoomOrDoorFrom({R1},{D}) -).</span>
<span class="plain">To change (D - direction) exit of (R1 - room) to (R2 - room)</span>
<span class="plain">(documented at ph_changeexit):</span>
<span class="plain">(- AssertMapConnection({R1},{D},{R2}); -).</span>
<span class="plain">To change (D - direction) exit of (R1 - room) to nothing/nowhere</span>
<span class="plain">(documented at ph_changenoexit):</span>
<span class="plain">(- AssertMapConnection({R1},{D},nothing); -).</span>
<span class="plain">To decide which room is the front side of (D - object)</span>
<span class="plain">(documented at ph_frontside):</span>
<span class="plain">(- FrontSideOfDoor({D}) -).</span>
<span class="plain">To decide which room is the back side of (D - object)</span>
<span class="plain">(documented at ph_backside):</span>
<span class="plain">(- BackSideOfDoor({D}) -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP63"></a><b>&#167;63. </b>Route-finding.
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/5/10 - Model world - Route-finding (for interactive fiction language element only)</span>
<span class="plain">To decide which object is best route from (R1 - object) to (R2 - object),</span>
<span class="plain">using doors or using even locked doors</span>
<span class="plain">(documented at ph_bestroute):</span>
<span class="plain">(- MapRouteTo({R1},{R2},0,{phrase options}) -).</span>
<span class="plain">To decide which number is number of moves from (R1 - object) to (R2 - object),</span>
<span class="plain">using doors or using even locked doors</span>
<span class="plain">(documented at ph_bestroutelength):</span>
<span class="plain">(- MapRouteTo({R1},{R2},0,{phrase options},true) -).</span>
<span class="plain">To decide which object is best route from (R1 - object) to (R2 - object) through</span>
<span class="plain">(RS - description of objects),</span>
<span class="plain">using doors or using even locked doors</span>
<span class="plain">(documented at ph_bestroutethrough):</span>
<span class="plain">(- MapRouteTo({R1},{R2},{RS},{phrase options}) -).</span>
<span class="plain">To decide which number is number of moves from (R1 - object) to (R2 - object) through</span>
<span class="plain">(RS - description of objects),</span>
<span class="plain">using doors or using even locked doors</span>
<span class="plain">(documented at ph_bestroutethroughlength):</span>
<span class="plain">(- MapRouteTo({R1},{R2},{RS},{phrase options},true) -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP64"></a><b>&#167;64. </b>The object tree.
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/5/11 - Model world - The object tree (for interactive fiction language element only)</span>
<span class="plain">To decide which object is holder of (something - object)</span>
<span class="plain">(documented at ph_holder):</span>
<span class="plain">(- (HolderOf({something})) -).</span>
<span class="plain">To decide which object is next thing held after (something - object)</span>
<span class="plain">(documented at ph_nextheld):</span>
<span class="plain">(- (sibling({something})) -).</span>
<span class="plain">To decide which object is first thing held by (something - object)</span>
<span class="plain">(documented at ph_firstheld):</span>
<span class="plain">(- (child({something})) -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP65"></a><b>&#167;65. Understanding. </b>First, asking yes/no questions.
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/6/1 - Understanding - Asking yes/no questions</span>
<span class="plain">To decide whether player consents</span>
<span class="plain">(documented at ph_consents):</span>
<span class="plain">(- YesOrNo() -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP66"></a><b>&#167;66. </b>Support for snippets, which are substrings of the player's command.
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/6/2 - Understanding - The player's command (for interactive fiction language element only)</span>
<span class="plain">To decide if (S - a snippet) matches (T - a topic)</span>
<span class="plain">(documented at ph_snippetmatches):</span>
<span class="plain">(- (SnippetMatches({S}, {T})) -).</span>
<span class="plain">To decide if (S - a snippet) does not match (T - a topic)</span>
<span class="plain">(documented at ph_snippetdoesnotmatch):</span>
<span class="plain">(- (SnippetMatches({S}, {T}) == false) -).</span>
<span class="plain">To decide if (S - a snippet) includes (T - a topic)</span>
<span class="plain">(documented at ph_snippetincludes):</span>
<span class="plain">(- (matched_text=SnippetIncludes({T},{S})) -).</span>
<span class="plain">To decide if (S - a snippet) does not include (T - a topic)</span>
<span class="plain">(documented at ph_snippetdoesnotinclude):</span>
<span class="plain">(- (SnippetIncludes({T},{S})==0) -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP67"></a><b>&#167;67. </b>Changing the player's command.
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/6/3 - Understanding - Changing the player's command (for interactive fiction language element only)</span>
<span class="plain">To change the text of the player's command to (T - text)</span>
<span class="plain">(documented at ph_changecommand):</span>
<span class="plain">(- SetPlayersCommand({-by-reference:T}); -).</span>
<span class="plain">To replace (S - a snippet) with (T - text)</span>
<span class="plain">(documented at ph_replacesnippet):</span>
<span class="plain">(- SpliceSnippet({S}, {-by-reference:T}); -).</span>
<span class="plain">To cut (S - a snippet)</span>
<span class="plain">(documented at ph_cutsnippet):</span>
<span class="plain">(- SpliceSnippet({S}, 0); -).</span>
<span class="plain">To reject the player's command</span>
<span class="plain">(documented at ph_rejectcommand):</span>
<span class="plain">(- RulebookFails(); rtrue; -) - in to only.</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP68"></a><b>&#167;68. </b>Scope and pronouns.
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/6/4 - Understanding - Scope and pronouns (for interactive fiction language element only)</span>
<span class="plain">To place (O - an object) in scope, but not its contents</span>
<span class="plain">(documented at ph_placeinscope):</span>
<span class="plain">(- PlaceInScope({O}, {phrase options}); -).</span>
<span class="plain">To place the/-- contents of (O - an object) in scope</span>
<span class="plain">(documented at ph_placecontentsinscope):</span>
<span class="plain">(- ScopeWithin({O}); -).</span>
<span class="plain">To set pronouns from (O - an object)</span>
<span class="plain">(documented at ph_setpronouns):</span>
<span class="plain">(- PronounNotice({O}); -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP69"></a><b>&#167;69. Message support. </b>"Unindexed" here is a euphemism for "undocumented". This is where
2019-03-17 14:40:57 +02:00
experimental or intermediate phrases go: things we don't want people
to use because we will probably revise them heavily in later builds of
Inform. For now, the Standard Rules do make use of these phrases, but
nobody else should. They will change without comment in the change
log.
</p>
<pre class="display">
<span class="plain">Section SR5/8/1 - Message support - Issuance - Unindexed</span>
<span class="plain">To issue score notification message:</span>
<span class="plain">(- NotifyTheScore(); -).</span>
<span class="plain">To say pronoun dictionary word:</span>
<span class="plain">(- print (address) pronoun_word; -).</span>
<span class="plain">To say recap of command:</span>
<span class="plain">(- PrintCommand(); -).</span>
<span class="plain">The pronoun reference object is an object that varies.</span>
<span class="plain">The pronoun reference object variable translates into I6 as "pronoun_obj".</span>
<span class="plain">To say pronoun i6 dictionary word:</span>
<span class="plain">(- print (address) pronoun_word; -).</span>
<span class="plain">To say parser command so far:</span>
<span class="plain">(- PrintCommand(); -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP70"></a><b>&#167;70. Miscellaneous other phrases. </b>Again, these are not part of Inform's public specification.
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">Section SR5/9/1 - Miscellaneous other phrases - Unindexed (for interactive fiction language element only)</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP71"></a><b>&#167;71. </b>These are actually sensible concepts in the world model, and could even
2019-03-17 14:40:57 +02:00
be opened to public use, but they're quite complicated to explain.
</p>
<pre class="display">
<span class="plain">To decide which object is the component parts core of (X - an object):</span>
<span class="plain">(- CoreOf({X}) -).</span>
<span class="plain">To decide which object is the common ancestor of (O - an object) with</span>
<span class="plain">(P - an object):</span>
<span class="plain">(- (CommonAncestor({O}, {P})) -).</span>
<span class="plain">To decide which object is the not-counting-parts holder of (O - an object):</span>
<span class="plain">(- (CoreOfParentOfCoreOf({O})) -).</span>
<span class="plain">To decide which object is the visibility-holder of (O - object):</span>
<span class="plain">(- VisibilityParent({O}) -).</span>
<span class="plain">To calculate visibility ceiling at low level:</span>
<span class="plain">(- FindVisibilityLevels(); -).</span>
<span class="plain">To decide which object is the touchability ceiling of (O - object):</span>
<span class="plain">(- TouchabilityCeiling({O}) -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP72"></a><b>&#167;72. </b>These are in effect global variables, but aren't defined as such, to
2019-03-17 14:40:57 +02:00
prevent people using them. Their contents are only very briefly meaningful,
and they would be dangerous friends to know.
</p>
<pre class="display">
<span class="plain">To decide which number is the visibility ceiling count calculated:</span>
<span class="plain">(- visibility_levels -).</span>
<span class="plain">To decide which object is the visibility ceiling calculated:</span>
<span class="plain">(- visibility_ceiling -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP73"></a><b>&#167;73. </b>This is a unique quasi-action, using the secondary action processing
2019-03-17 14:40:57 +02:00
stage only. A convenience, but also an anomaly, and let's not encourage
its further use.
</p>
<pre class="display">
<span class="plain">To produce a room description with going spacing conventions:</span>
<span class="plain">(- LookAfterGoing(); -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP74"></a><b>&#167;74. </b>An ugly little trick needed because of the mismatch between I6 and I7
2019-03-17 14:40:57 +02:00
property implementation, and because of legacy code from the old I6 library.
Please don't touch.
</p>
<pre class="display">
<span class="plain">To print the location's description:</span>
<span class="plain">(- PrintOrRun(location, description); -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP75"></a><b>&#167;75. </b>This avoids "mentioned" being given to items printed only internally for
2019-03-17 14:40:57 +02:00
the sake of a string comparison, and not shown on screen.
</p>
<pre class="display">
<span class="plain">To decide if expanding text for comparison purposes:</span>
<span class="plain">(- say__comp -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP76"></a><b>&#167;76. </b>This is a bit trickier than it looks, because it isn't always set when
2019-03-17 14:40:57 +02:00
one thinks it is.
</p>
<pre class="display">
<span class="plain">To decide whether the I6 parser is running multiple actions:</span>
<span class="plain">(- (multiflag==1) -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP77"></a><b>&#167;77. </b>Again, the following cries out for an enumerated kind of value.
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">To decide if set to sometimes abbreviated room descriptions:</span>
<span class="plain">(- (lookmode == 1) -).</span>
<span class="plain">To decide if set to unabbreviated room descriptions:</span>
<span class="plain">(- (lookmode == 2) -).</span>
<span class="plain">To decide if set to abbreviated room descriptions:</span>
<span class="plain">(- (lookmode == 3) -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP78"></a><b>&#167;78. </b>Action conversion is a trick used in the Standard Rules to simplify the
2019-03-17 14:40:57 +02:00
implementation of actions: it allows one action to become another one
mid-way, without causing spurious action failures. (There are better ways
to make user-defined actions convert, and some of the examples show this.)
</p>
<pre class="display">
<span class="plain">To convert to (AN - an action name) on (O - an object):</span>
<span class="plain">(- return GVS_Convert({AN},{O},0); -) - in to only.</span>
<span class="plain">To convert to request of (X - object) to perform (AN - action name) with</span>
<span class="plain">(Y - object) and (Z - object):</span>
<span class="plain">(- return ConvertToRequest({X}, {AN}, {Y}, {Z}); -).</span>
<span class="plain">To convert to special going-with-push action:</span>
<span class="plain">(- return ConvertToGoingWithPush(); -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP79"></a><b>&#167;79. </b>The "surreptitiously" phrases shouldn't be used except in the Standard Rules
2019-03-17 14:40:57 +02:00
because they temporarily violate invariants for the object tree and the
light variables; the SR uses them carefully in situations where it's known to
work out all right.
</p>
<pre class="display">
<span class="plain">To surreptitiously move (something - object) to (something else - object):</span>
<span class="plain">(- move {something} to {something else}; -).</span>
<span class="plain">To surreptitiously move (something - object) to (something else - object) during going:</span>
<span class="plain">(- MoveDuringGoing({something}, {something else}); -).</span>
<span class="plain">To surreptitiously reckon darkness:</span>
<span class="plain">(- SilentlyConsiderLight(); -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP80"></a><b>&#167;80. </b>These are text substitutions needed to make the capitalised lists work.
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">To say list-writer list of marked objects: (-</span>
<span class="plain">WriteListOfMarkedObjects(ENGLISH_BIT);</span>
<span class="plain">-).</span>
<span class="plain">To say list-writer articled list of marked objects: (-</span>
<span class="plain">WriteListOfMarkedObjects(ENGLISH_BIT+DEFART_BIT+CFIRSTART_BIT);</span>
<span class="plain">-).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP81"></a><b>&#167;81. </b>This is convenient for debugging Inform, but for no other purpose. It
2019-03-17 14:40:57 +02:00
toggles verbose logging of the type-checker.
</p>
<pre class="display">
<span class="plain">Section SR5/9/2 - Debugging Inform - Unindexed</span>
<span class="plain">To ***:</span>
<span class="plain">(- {-primitive-definition:verbose-checking} -).</span>
<span class="plain">To *** (T - text):</span>
<span class="plain">(- {-primitive-definition:verbose-checking} -).</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP82"></a><b>&#167;82. </b>And so, at last...
2019-03-17 14:40:57 +02:00
</p>
<pre class="display">
<span class="plain">The Standard Rules end here.</span>
</pre>
<p class="inwebparagraph"></p>
2020-01-13 13:02:57 +02:00
<p class="inwebparagraph"><a id="SP83"></a><b>&#167;83. </b>...except that this is not quite true, because like most extensions they
2019-03-17 14:40:57 +02:00
then quote some documentation for Inform to weave into index pages: though
here it's more of a polite refusal than a manual, since the entire system
documentation is really the description of what was defined in this
extension.
</p>
<pre class="display">
<span class="plain">---- DOCUMENTATION ----</span>
<span class="plain">Unlike other extensions, the Standard Rules are compulsorily included</span>
<span class="plain">with every project. They define the phrases, kinds and relations which</span>
<span class="plain">are basic to Inform, and which are described throughout the documentation.</span>
</pre>
<p class="inwebparagraph"></p>
<hr class="tocbar">
<ul class="toc"><li><a href="S-act2.html">Back to 'Actions'</a></li><li><i>(This section ends Sections.)</i></li></ul><hr class="tocbar">
2019-04-22 17:42:10 +03:00
<!--End of weave-->
2019-03-17 14:40:57 +02:00
</body>
</html>