1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-06-26 04:00:43 +03:00

New example file format for documentation

This commit is contained in:
Graham Nelson 2023-07-24 11:56:58 +01:00
parent 2c84a758d1
commit cab0cf5175
1204 changed files with 20741 additions and 20134 deletions

View file

@ -1,6 +1,6 @@
# Inform 7
[Version](notes/versioning.md): 10.2.0-beta+6W89 'Krypton' (23 July 2023)
[Version](notes/versioning.md): 10.2.0-beta+6W90 'Krypton' (24 July 2023)
## About Inform

View file

@ -1,3 +1,3 @@
Prerelease: beta
Build Date: 23 July 2023
Build Number: 6W89
Build Date: 24 July 2023
Build Number: 6W90

View file

@ -59,7 +59,7 @@ function togglePopup(material_id) {
<ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="index.html">indoc</a></li><li><a href="index.html#2">Chapter 2: Processing</a></li><li><b>Examples</b></li></ul></div>
<p class="purpose">Keeping track of the metadata on and sequencing of the examples.</p>
<ul class="toc"><li><a href="2-exm.html#SP4">&#167;4. Example scanning</a></li><li><a href="2-exm.html#SP7">&#167;7. Rendering example cues</a></li></ul><hr class="tocbar">
<ul class="toc"><li><a href="2-exm.html#SP4">&#167;4. Example scanning</a></li><li><a href="2-exm.html#SP5">&#167;5. Rendering example cues</a></li></ul><hr class="tocbar">
<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. </b>Examples are created in no particular order, and their allocation numbers
do not necessarily correspond to the numbering displayed in the final
@ -79,11 +79,12 @@ the current volume), so we also need to remember where it will actually go.
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ex_filename</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ex_outline</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ex_public_name</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ex_rubric</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ex_rubric_pared_down</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ex_index</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ex_subtitle</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ex_stars</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ex_sort_key</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">ex_star_count</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">ex_header_length</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">section</span><span class="plain-syntax"> *</span><span class="identifier-syntax">example_belongs_to_section</span><span class="plain-syntax">[</span><span class="constant-syntax">MAX_VOLUMES</span><span class="plain-syntax">]; </span><span class="comment-syntax"> e.g., an example might belong to section 7</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">section</span><span class="plain-syntax"> *</span><span class="identifier-syntax">example_displayed_at_section</span><span class="plain-syntax">[</span><span class="constant-syntax">MAX_VOLUMES</span><span class="plain-syntax">]; </span><span class="comment-syntax"> but be held back and appear at end of section 23</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">example_position</span><span class="plain-syntax">[</span><span class="constant-syntax">MAX_VOLUMES</span><span class="plain-syntax">]; </span><span class="comment-syntax"> sequence, counting from 0</span>
@ -95,7 +96,7 @@ the current volume), so we also need to remember where it will actually go.
of their names:
</p>
<pre class="definitions code-font"><span class="definition-keyword">define</span> <span class="constant-syntax">MAX_EXAMPLES</span><span class="plain-syntax"> </span><span class="constant-syntax">1000</span>
<pre class="definitions code-font"><span class="definition-keyword">define</span> <span class="constant-syntax">MAX_EXAMPLES</span><span class="plain-syntax"> </span><span class="constant-syntax">10000</span>
</pre>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">examples</span><span class="plain-syntax">[</span><span class="constant-syntax">MAX_EXAMPLES</span><span class="plain-syntax">];</span>
@ -108,7 +109,6 @@ of their names:
<span class="reserved-syntax">dictionary</span><span class="plain-syntax"> *</span><span class="identifier-syntax">recipe_location</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">dictionary</span><span class="plain-syntax"> *</span><span class="identifier-syntax">recipe_sort_prefix</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">dictionary</span><span class="plain-syntax"> *</span><span class="identifier-syntax">recipe_subheading_of</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">dictionary</span><span class="plain-syntax"> *</span><span class="identifier-syntax">recipe_translates_as</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
</pre>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. Example scanning. </b>Each Example has its own file, which consists of a three-line header, and
then some rawtext. The following scanner goes through a whole directory
@ -135,11 +135,14 @@ Inform documentation.
<span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entry</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/1-wp.html#SP4" class="function-link"><span class="function-syntax">Platform::is_folder_separator</span></a><span class="plain-syntax">(</span><a href="../../../inweb/foundation-module/4-sm.html#SP13" class="function-link"><span class="function-syntax">Str::get_last_char</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">))) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP26" class="function-link"><span class="function-syntax">Str::includes</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"-I."</span><span class="plain-syntax">)) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">exloc</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/3-fln.html#SP2" class="function-link"><span class="function-syntax">Filenames::in</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">indoc_settings</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">examples_directory</span><span class="plain-syntax">, </span><span class="identifier-syntax">entry</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-pm.html#SP10" class="function-link"><span class="function-syntax">Regexp::match</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">entry</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"%(Recipes%)%c*"</span><span class="plain-syntax">)) </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP4_2" class="named-paragraph-link"><span class="named-paragraph">Scan the Recipe Book catalogue</span><span class="named-paragraph-number">4.2</span></a></span>
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP4_1" class="named-paragraph-link"><span class="named-paragraph">Scan a regular example</span><span class="named-paragraph-number">4.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">E</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">example</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP4_1" class="named-paragraph-link"><span class="named-paragraph">Initialise the example</span><span class="named-paragraph-number">4.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">no_examples</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">MAX_EXAMPLES</span><span class="plain-syntax">) </span><a href="../../../inweb/foundation-module/3-em.html#SP2" class="function-link"><span class="function-syntax">Errors::fatal</span></a><span class="plain-syntax">(</span><span class="string-syntax">"too many examples"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">examples</span><span class="plain-syntax">[</span><span class="identifier-syntax">no_examples</span><span class="plain-syntax">++] = </span><span class="identifier-syntax">E</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP4_2" class="named-paragraph-link"><span class="named-paragraph">Scan the example</span><span class="named-paragraph-number">4.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP4_3" class="named-paragraph-link"><span class="named-paragraph">Use the Recipe Book catalogue to place examples in the RB</span><span class="named-paragraph-number">4.3</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">V</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">LOOP_OVER</span><span class="plain-syntax">(</span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="reserved-syntax">volume</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP4_4" class="named-paragraph-link"><span class="named-paragraph">Work out the sequence of examples within this volume</span><span class="named-paragraph-number">4.4</span></a></span><span class="plain-syntax">;</span>
@ -147,227 +150,118 @@ Inform documentation.
<span class="plain-syntax"> }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP4_1" class="paragraph-anchor"></a><b>&#167;4.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Scan a regular example</span><span class="named-paragraph-number">4.1</span></span><span class="comment-syntax"> =</span>
<p class="commentary firstcommentary"><a id="SP4_1" class="paragraph-anchor"></a><b>&#167;4.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Initialise the example</span><span class="named-paragraph-number">4.1</span></span><span class="comment-syntax"> =</span>
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_filename</span><span class="plain-syntax"> = </span><span class="identifier-syntax">exloc</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_outline</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_public_name</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_index</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_subtitle</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_stars</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_sort_key</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_star_count</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_header_length</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">example_belongs_to_section</span><span class="plain-syntax">[0] = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">example_belongs_to_section</span><span class="plain-syntax">[1] = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">example_displayed_at_section</span><span class="plain-syntax">[0] = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">example_displayed_at_section</span><span class="plain-syntax">[1] = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">example_position</span><span class="plain-syntax">[0] = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">example_position</span><span class="plain-syntax">[1] = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP4">&#167;4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_2" class="paragraph-anchor"></a><b>&#167;4.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Scan the example</span><span class="named-paragraph-number">4.2</span></span><span class="comment-syntax"> =</span>
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax"> </span><span class="reserved-syntax">example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">E</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">example</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">no_examples</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">MAX_EXAMPLES</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/3-em.html#SP2" class="function-link"><span class="function-syntax">Errors::fatal</span></a><span class="plain-syntax">(</span><span class="string-syntax">"too many examples"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">examples</span><span class="plain-syntax">[</span><span class="identifier-syntax">no_examples</span><span class="plain-syntax">++] = </span><span class="identifier-syntax">E</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">examples_helper_state</span><span class="plain-syntax"> </span><span class="identifier-syntax">ehs</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">ehs</span><span class="plain-syntax">.</span><span class="element-syntax">E</span><span class="plain-syntax"> = </span><span class="identifier-syntax">E</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">ehs</span><span class="plain-syntax">.</span><span class="element-syntax">ef</span><span class="plain-syntax"> = </span><span class="identifier-syntax">exloc</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">ehs</span><span class="plain-syntax">.</span><span class="element-syntax">body_reached</span><span class="plain-syntax"> = </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-tf.html#SP5" class="function-link"><span class="function-syntax">TextFiles::read</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">exloc</span><span class="plain-syntax">, </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">, </span><span class="string-syntax">"can't read example file"</span><span class="plain-syntax">,</span>
<span class="plain-syntax"> </span><span class="constant-syntax">TRUE</span><span class="plain-syntax">, </span><a href="2-exm.html#SP5" class="function-link"><span class="function-syntax">Examples::examples_helper</span></a><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, &amp;</span><span class="identifier-syntax">ehs</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="constant-syntax">TRUE</span><span class="plain-syntax">, </span><a href="2-exm.html#SP4_3" class="function-link"><span class="function-syntax">Examples::examples_helper</span></a><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, &amp;</span><span class="identifier-syntax">ehs</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP4">&#167;4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. </b></p>
<p class="commentary firstcommentary"><a id="SP4_3" class="paragraph-anchor"></a><b>&#167;4.3. </b></p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">examples_helper_state</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">E</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ef</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">body_reached</span><span class="plain-syntax">;</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">examples_helper_state</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Examples::examples_helper</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">Examples::examples_helper</span></span>:<br/><a href="2-exm.html#SP4_1">&#167;4.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">line</span><span class="plain-syntax">, </span><span class="reserved-syntax">text_file_position</span><span class="plain-syntax"> *</span><span class="identifier-syntax">tfp</span><span class="plain-syntax">, </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">v_ehs</span><span class="plain-syntax">) {</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Examples::examples_helper</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">Examples::examples_helper</span></span>:<br/><a href="2-exm.html#SP4_2">&#167;4.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">line</span><span class="plain-syntax">, </span><span class="reserved-syntax">text_file_position</span><span class="plain-syntax"> *</span><span class="identifier-syntax">tfp</span><span class="plain-syntax">, </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">v_ehs</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">examples_helper_state</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ehs</span><span class="plain-syntax"> = (</span><span class="reserved-syntax">examples_helper_state</span><span class="plain-syntax"> *) </span><span class="identifier-syntax">v_ehs</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">E</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ehs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">E</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP24" class="function-link"><span class="function-syntax">Str::trim_white_space_at_end</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">line</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP24" class="function-link"><span class="function-syntax">Str::trim_white_space</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">line</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ehs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">body_reached</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP23" class="function-link"><span class="function-syntax">Str::is_whitespace</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">line</span><span class="plain-syntax">)) { </span><span class="identifier-syntax">ehs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">body_reached</span><span class="plain-syntax"> = </span><span class="constant-syntax">TRUE</span><span class="plain-syntax">; </span><span class="reserved-syntax">return</span><span class="plain-syntax">; }</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_header_length</span><span class="plain-syntax">++;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">match_results</span><span class="plain-syntax"> </span><span class="identifier-syntax">mr</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/4-pm.html#SP9" class="function-link"><span class="function-syntax">Regexp::create_mr</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tfp</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">line_count</span><span class="plain-syntax"> == </span><span class="constant-syntax">1</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP5_1" class="named-paragraph-link"><span class="named-paragraph">Scan line 1 of the example header</span><span class="named-paragraph-number">5.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tfp</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">line_count</span><span class="plain-syntax"> == </span><span class="constant-syntax">2</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP5_2" class="named-paragraph-link"><span class="named-paragraph">Scan line 2 of the example header</span><span class="named-paragraph-number">5.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tfp</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">line_count</span><span class="plain-syntax"> == </span><span class="constant-syntax">3</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP5_3" class="named-paragraph-link"><span class="named-paragraph">Scan line 3 of the example header</span><span class="named-paragraph-number">5.3</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tfp</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">line_count</span><span class="plain-syntax"> == </span><span class="constant-syntax">1</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-pm.html#SP10" class="function-link"><span class="function-syntax">Regexp::match</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">line</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"Example *: *(%*+) (%c*)"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">asterisk_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[0];</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">name</span><span class="plain-syntax"> = </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[1];</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_stars</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/4-sm.html#SP3" class="function-link"><span class="function-syntax">Str::duplicate</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">asterisk_text</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">starc</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP22" class="function-link"><span class="function-syntax">Str::eq_wide_string</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_stars</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"*"</span><span class="plain-syntax">)) </span><span class="identifier-syntax">starc</span><span class="plain-syntax">=1;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP22" class="function-link"><span class="function-syntax">Str::eq_wide_string</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_stars</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"**"</span><span class="plain-syntax">)) </span><span class="identifier-syntax">starc</span><span class="plain-syntax">=2;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP22" class="function-link"><span class="function-syntax">Str::eq_wide_string</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_stars</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"***"</span><span class="plain-syntax">)) </span><span class="identifier-syntax">starc</span><span class="plain-syntax">=3;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP22" class="function-link"><span class="function-syntax">Str::eq_wide_string</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_stars</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"****"</span><span class="plain-syntax">)) </span><span class="identifier-syntax">starc</span><span class="plain-syntax">=4;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">starc</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/3-em.html#SP5" class="function-link"><span class="function-syntax">Errors::in_text_file</span></a><span class="plain-syntax">(</span><span class="string-syntax">"star count for example must be * to ****"</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">starc</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_star_count</span><span class="plain-syntax"> = </span><span class="identifier-syntax">starc</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_public_name</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/4-sm.html#SP3" class="function-link"><span class="function-syntax">Str::duplicate</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">name</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">examples_by_name</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">examples_by_name</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/2-dct.html#SP2" class="function-link"><span class="function-syntax">Dictionaries::new</span></a><span class="plain-syntax">(100, </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/2-dct.html#SP5" class="function-link"><span class="function-syntax">Dictionaries::create</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">examples_by_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">name</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/2-dct.html#SP8" class="function-link"><span class="function-syntax">Dictionaries::write_value</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">examples_by_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">name</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/3-em.html#SP5" class="function-link"><span class="function-syntax">Errors::in_text_file</span></a><span class="plain-syntax">(</span><span class="string-syntax">"first line should read 'Example: ** Title'"</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-pm.html#SP10" class="function-link"><span class="function-syntax">Regexp::match</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">line</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"(%C+?) *: *(%c*)"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">field</span><span class="plain-syntax"> = </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[0];</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">content</span><span class="plain-syntax"> = </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[1];</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP19" class="function-link"><span class="function-syntax">Str::eq</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">field</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"Example"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/3-em.html#SP5" class="function-link"><span class="function-syntax">Errors::in_text_file</span></a><span class="plain-syntax">(</span><span class="string-syntax">"'Example:' should be on line 1"</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP19" class="function-link"><span class="function-syntax">Str::eq</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">field</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"Location"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">sname</span><span class="plain-syntax"> = </span><span class="identifier-syntax">content</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">section</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/2-dct.html#SP8" class="function-link"><span class="function-syntax">Dictionaries::read_value</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">volumes</span><span class="plain-syntax">[0]-&gt;</span><span class="element-syntax">sections_by_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">sname</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">S</span><span class="plain-syntax">) </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">example_belongs_to_section</span><span class="plain-syntax">[0] = </span><span class="identifier-syntax">S</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">example_belongs_to_section</span><span class="plain-syntax">[0] = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/3-em.html#SP5" class="function-link"><span class="function-syntax">Errors::in_text_file</span></a><span class="plain-syntax">(</span><span class="string-syntax">"example belongs to an unknown section"</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_filename</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ehs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ef</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP19" class="function-link"><span class="function-syntax">Str::eq</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">field</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"Description"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_outline</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/4-sm.html#SP3" class="function-link"><span class="function-syntax">Str::duplicate</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">content</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP19" class="function-link"><span class="function-syntax">Str::eq</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">field</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"For"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax"> ; </span><span class="comment-syntax"> not relevant to indoc</span>
<span class="plain-syntax"> } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP19" class="function-link"><span class="function-syntax">Str::eq</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">field</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"Index"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_index</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/4-sm.html#SP3" class="function-link"><span class="function-syntax">Str::duplicate</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">content</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP19" class="function-link"><span class="function-syntax">Str::eq</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">field</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"Subtitle"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_subtitle</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/4-sm.html#SP3" class="function-link"><span class="function-syntax">Str::duplicate</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">content</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP19" class="function-link"><span class="function-syntax">Str::eq</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">field</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"RecipeLocation"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">sname</span><span class="plain-syntax"> = </span><span class="identifier-syntax">content</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">section</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/2-dct.html#SP8" class="function-link"><span class="function-syntax">Dictionaries::read_value</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">volumes</span><span class="plain-syntax">[1]-&gt;</span><span class="element-syntax">sections_by_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">sname</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">S</span><span class="plain-syntax">) </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">example_belongs_to_section</span><span class="plain-syntax">[1] = </span><span class="identifier-syntax">S</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">example_belongs_to_section</span><span class="plain-syntax">[1] = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/3-em.html#SP5" class="function-link"><span class="function-syntax">Errors::in_text_file</span></a><span class="plain-syntax">(</span><span class="string-syntax">"example belongs to an unknown section"</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/3-em.html#SP5" class="function-link"><span class="function-syntax">Errors::in_text_file</span></a><span class="plain-syntax">(</span><span class="string-syntax">"no such example details field"</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-pm.html#SP9" class="function-link"><span class="function-syntax">Regexp::dispose_of</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>The structure examples_helper_state is accessed in 2/rr and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP5_1" class="paragraph-anchor"></a><b>&#167;5.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Scan line 1 of the example header</span><span class="named-paragraph-number">5.1</span></span><span class="comment-syntax"> =</span>
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-pm.html#SP10" class="function-link"><span class="function-syntax">Regexp::match</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">line</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">" *(%*+) (%c*)"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">asterisk_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[0];</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">sname</span><span class="plain-syntax"> = </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[1];</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">ex_stars</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/4-sm.html#SP3" class="function-link"><span class="function-syntax">Str::duplicate</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">asterisk_text</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">starc</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP22" class="function-link"><span class="function-syntax">Str::eq_wide_string</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_stars</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"*"</span><span class="plain-syntax">)) </span><span class="identifier-syntax">starc</span><span class="plain-syntax">=1;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP22" class="function-link"><span class="function-syntax">Str::eq_wide_string</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_stars</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"**"</span><span class="plain-syntax">)) </span><span class="identifier-syntax">starc</span><span class="plain-syntax">=2;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP22" class="function-link"><span class="function-syntax">Str::eq_wide_string</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_stars</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"***"</span><span class="plain-syntax">)) </span><span class="identifier-syntax">starc</span><span class="plain-syntax">=3;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP22" class="function-link"><span class="function-syntax">Str::eq_wide_string</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_stars</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"****"</span><span class="plain-syntax">)) </span><span class="identifier-syntax">starc</span><span class="plain-syntax">=4;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">starc</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/3-em.html#SP5" class="function-link"><span class="function-syntax">Errors::in_text_file</span></a><span class="plain-syntax">(</span><span class="string-syntax">"star count for example must be * to ****"</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">starc</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">ex_star_count</span><span class="plain-syntax"> = </span><span class="identifier-syntax">starc</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">section</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/2-dct.html#SP8" class="function-link"><span class="function-syntax">Dictionaries::read_value</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">volumes</span><span class="plain-syntax">[0]-&gt;</span><span class="element-syntax">sections_by_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">sname</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">S</span><span class="plain-syntax">) </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">example_belongs_to_section</span><span class="plain-syntax">[0] = </span><span class="identifier-syntax">S</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">example_belongs_to_section</span><span class="plain-syntax">[0] = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/3-em.html#SP5" class="function-link"><span class="function-syntax">Errors::in_text_file</span></a><span class="plain-syntax">(</span><span class="string-syntax">"example belongs to an unknown section"</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">ex_filename</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ehs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ef</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/3-em.html#SP5" class="function-link"><span class="function-syntax">Errors::in_text_file</span></a><span class="plain-syntax">(</span><span class="string-syntax">"example has a malformed first line"</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP5">&#167;5</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP5_2" class="paragraph-anchor"></a><b>&#167;5.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Scan line 2 of the example header</span><span class="named-paragraph-number">5.2</span></span><span class="comment-syntax"> =</span>
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-pm.html#SP10" class="function-link"><span class="function-syntax">Regexp::match</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">line</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">" *%((%c*?)%)"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">match_results</span><span class="plain-syntax"> </span><span class="identifier-syntax">mr2</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/4-pm.html#SP9" class="function-link"><span class="function-syntax">Regexp::create_mr</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">ex_rubric</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/4-sm.html#SP3" class="function-link"><span class="function-syntax">Str::duplicate</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">rb</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">rb</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_rubric</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-pm.html#SP10" class="function-link"><span class="function-syntax">Regexp::match</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr2</span><span class="plain-syntax">, </span><span class="identifier-syntax">rb</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"(%c*?) *-- *(%c*)"</span><span class="plain-syntax">)) </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">rb</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr2</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-pm.html#SP10" class="function-link"><span class="function-syntax">Regexp::match</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr2</span><span class="plain-syntax">, </span><span class="identifier-syntax">rb</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"(%c*); *(%c*?)"</span><span class="plain-syntax">)) </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">rb</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr2</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-pm.html#SP10" class="function-link"><span class="function-syntax">Regexp::match</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr2</span><span class="plain-syntax">, </span><span class="identifier-syntax">rb</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"(%c*?): *(%c*?)"</span><span class="plain-syntax">)) </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">rb</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr2</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">ex_rubric_pared_down</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/4-sm.html#SP3" class="function-link"><span class="function-syntax">Str::duplicate</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">rb</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">rb</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">name</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">name</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_rubric</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-pm.html#SP10" class="function-link"><span class="function-syntax">Regexp::match</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr2</span><span class="plain-syntax">, </span><span class="identifier-syntax">name</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"%c*;(%c*?)"</span><span class="plain-syntax">)) </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">name</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr2</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-pm.html#SP10" class="function-link"><span class="function-syntax">Regexp::match</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr2</span><span class="plain-syntax">, </span><span class="identifier-syntax">name</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"(%c*?): (%d+). %c*"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP15" class="function-link"><span class="function-syntax">Str::clear</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">name</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">name</span><span class="plain-syntax">, </span><span class="string-syntax">"%S %S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr2</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[0], </span><span class="identifier-syntax">mr2</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP24" class="function-link"><span class="function-syntax">Str::trim_white_space</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">name</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">ex_public_name</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/4-sm.html#SP3" class="function-link"><span class="function-syntax">Str::duplicate</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">name</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">examples_by_name</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">examples_by_name</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/2-dct.html#SP2" class="function-link"><span class="function-syntax">Dictionaries::new</span></a><span class="plain-syntax">(100, </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/2-dct.html#SP5" class="function-link"><span class="function-syntax">Dictionaries::create</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">examples_by_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">name</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/2-dct.html#SP8" class="function-link"><span class="function-syntax">Dictionaries::write_value</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">examples_by_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">name</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">name</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-pm.html#SP9" class="function-link"><span class="function-syntax">Regexp::dispose_of</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr2</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/3-em.html#SP5" class="function-link"><span class="function-syntax">Errors::in_text_file</span></a><span class="plain-syntax">(</span><span class="string-syntax">"example has a malformed second line"</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP5">&#167;5</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP5_3" class="paragraph-anchor"></a><b>&#167;5.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Scan line 3 of the example header</span><span class="named-paragraph-number">5.3</span></span><span class="comment-syntax"> =</span>
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_outline</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/4-sm.html#SP3" class="function-link"><span class="function-syntax">Str::duplicate</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">line</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP5">&#167;5</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_2" class="paragraph-anchor"></a><b>&#167;4.2. </b>The RB catalogue has a rather arcane format: see the file itself to be
</p>
<ul class="items"><li>(slightly) enlightened.
</li></ul>
<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Scan the Recipe Book catalogue</span><span class="named-paragraph-number">4.2</span></span><span class="comment-syntax"> =</span>
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax"> </span><span class="reserved-syntax">examples_rb_helper_state</span><span class="plain-syntax"> </span><span class="identifier-syntax">erbhs</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">erbhs</span><span class="plain-syntax">.</span><span class="identifier-syntax">current_rch</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/4-sm.html#SP2" class="function-link"><span class="function-syntax">Str::new</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">erbhs</span><span class="plain-syntax">.</span><span class="identifier-syntax">current_rcsh</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/4-sm.html#SP2" class="function-link"><span class="function-syntax">Str::new</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">erbhs</span><span class="plain-syntax">.</span><span class="identifier-syntax">no_recipe_headings</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">erbhs</span><span class="plain-syntax">.</span><span class="identifier-syntax">no_recipe_subheadings</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-tf.html#SP5" class="function-link"><span class="function-syntax">TextFiles::read</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">exloc</span><span class="plain-syntax">, </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">, </span><span class="string-syntax">"can't read Recipe Book catalogue file"</span><span class="plain-syntax">,</span>
<span class="plain-syntax"> </span><span class="constant-syntax">TRUE</span><span class="plain-syntax">, </span><a href="2-exm.html#SP6" class="function-link"><span class="function-syntax">Examples::examples_rb_helper</span></a><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, &amp;</span><span class="identifier-syntax">erbhs</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP4">&#167;4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. </b></p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">examples_rb_helper_state</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">current_rch</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">current_rcsh</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">no_recipe_headings</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">no_recipe_subheadings</span><span class="plain-syntax">;</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">examples_rb_helper_state</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Examples::examples_rb_helper</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">Examples::examples_rb_helper</span></span>:<br/><a href="2-exm.html#SP4_2">&#167;4.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">line</span><span class="plain-syntax">, </span><span class="reserved-syntax">text_file_position</span><span class="plain-syntax"> *</span><span class="identifier-syntax">tfp</span><span class="plain-syntax">, </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">v_erbhs</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">examples_rb_helper_state</span><span class="plain-syntax"> *</span><span class="identifier-syntax">erbhs</span><span class="plain-syntax"> = (</span><span class="reserved-syntax">examples_rb_helper_state</span><span class="plain-syntax"> *) </span><span class="identifier-syntax">v_erbhs</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP24" class="function-link"><span class="function-syntax">Str::trim_white_space</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">line</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">match_results</span><span class="plain-syntax"> </span><span class="identifier-syntax">mr</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/4-pm.html#SP9" class="function-link"><span class="function-syntax">Regexp::create_mr</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-pm.html#SP10" class="function-link"><span class="function-syntax">Regexp::match</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">line</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">" *(%c*?) *== *(%c*?)"</span><span class="plain-syntax">)) </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP6_1" class="named-paragraph-link"><span class="named-paragraph">Scan a translation line</span><span class="named-paragraph-number">6.1</span></a></span>
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-pm.html#SP10" class="function-link"><span class="function-syntax">Regexp::match</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">line</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"&gt;(%c*)"</span><span class="plain-syntax">)) </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP6_2" class="named-paragraph-link"><span class="named-paragraph">Scan a major heading</span><span class="named-paragraph-number">6.2</span></a></span>
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-pm.html#SP10" class="function-link"><span class="function-syntax">Regexp::match</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">line</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"%*(%c*)"</span><span class="plain-syntax">)) </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP6_3" class="named-paragraph-link"><span class="named-paragraph">Scan a minor heading</span><span class="named-paragraph-number">6.3</span></a></span>
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP8" class="function-link"><span class="function-syntax">Str::len</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">line</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP6_4" class="named-paragraph-link"><span class="named-paragraph">Scan an example name</span><span class="named-paragraph-number">6.4</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-pm.html#SP9" class="function-link"><span class="function-syntax">Regexp::dispose_of</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>The structure examples_rb_helper_state is private to this section.</li></ul>
<p class="commentary firstcommentary"><a id="SP6_1" class="paragraph-anchor"></a><b>&#167;6.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Scan a translation line</span><span class="named-paragraph-number">6.1</span></span><span class="comment-syntax"> =</span>
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">recipe_translates_as</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">recipe_translates_as</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/2-dct.html#SP2" class="function-link"><span class="function-syntax">Dictionaries::new</span></a><span class="plain-syntax">(100, </span><span class="constant-syntax">TRUE</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">trans</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/2-dct.html#SP9" class="function-link"><span class="function-syntax">Dictionaries::create_text</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">recipe_translates_as</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">trans</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[1]);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP6">&#167;6</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP6_2" class="paragraph-anchor"></a><b>&#167;6.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Scan a major heading</span><span class="named-paragraph-number">6.2</span></span><span class="comment-syntax"> =</span>
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">erbhs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">current_rch</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">erbhs</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">no_recipe_headings</span><span class="plain-syntax">++;</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP15" class="function-link"><span class="function-syntax">Str::clear</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">erbhs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">current_rcsh</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">erbhs</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">no_recipe_subheadings</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP6">&#167;6</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP6_3" class="paragraph-anchor"></a><b>&#167;6.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Scan a minor heading</span><span class="named-paragraph-number">6.3</span></span><span class="comment-syntax"> =</span>
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">erbhs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">current_rcsh</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">erbhs</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">no_recipe_subheadings</span><span class="plain-syntax">++;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP6">&#167;6</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP6_4" class="paragraph-anchor"></a><b>&#167;6.4. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Scan an example name</span><span class="named-paragraph-number">6.4</span></span><span class="comment-syntax"> =</span>
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">recipe_subheading_of</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">recipe_subheading_of</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/2-dct.html#SP2" class="function-link"><span class="function-syntax">Dictionaries::new</span></a><span class="plain-syntax">(100, </span><span class="constant-syntax">TRUE</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">rso</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/2-dct.html#SP9" class="function-link"><span class="function-syntax">Dictionaries::create_text</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">recipe_subheading_of</span><span class="plain-syntax">, </span><span class="identifier-syntax">line</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">rso</span><span class="plain-syntax">, </span><span class="identifier-syntax">erbhs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">current_rcsh</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">recipe_location</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">recipe_location</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/2-dct.html#SP2" class="function-link"><span class="function-syntax">Dictionaries::new</span></a><span class="plain-syntax">(100, </span><span class="constant-syntax">TRUE</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">rl</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/2-dct.html#SP9" class="function-link"><span class="function-syntax">Dictionaries::create_text</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">recipe_location</span><span class="plain-syntax">, </span><span class="identifier-syntax">line</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">rl</span><span class="plain-syntax">, </span><span class="identifier-syntax">erbhs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">current_rcsh</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP22" class="function-link"><span class="function-syntax">Str::eq_wide_string</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">line</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"About the examples"</span><span class="plain-syntax">)) </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">rl</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"PREFACE"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP22" class="function-link"><span class="function-syntax">Str::eq_wide_string</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">line</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"Basic room, container, and supporter descriptions"</span><span class="plain-syntax">))</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">rl</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"PREFACE"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">recipe_sort_prefix</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">recipe_sort_prefix</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/2-dct.html#SP2" class="function-link"><span class="function-syntax">Dictionaries::new</span></a><span class="plain-syntax">(100, </span><span class="constant-syntax">TRUE</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">rsp</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/2-dct.html#SP9" class="function-link"><span class="function-syntax">Dictionaries::create_text</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">recipe_sort_prefix</span><span class="plain-syntax">, </span><span class="identifier-syntax">line</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">rsp</span><span class="plain-syntax">, </span><span class="string-syntax">"%02d_%02d"</span><span class="plain-syntax">, </span><span class="identifier-syntax">erbhs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">no_recipe_headings</span><span class="plain-syntax">, </span><span class="identifier-syntax">erbhs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">no_recipe_subheadings</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP6">&#167;6</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_3" class="paragraph-anchor"></a><b>&#167;4.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Use the Recipe Book catalogue to place examples in the RB</span><span class="named-paragraph-number">4.3</span></span><span class="comment-syntax"> =</span>
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax"> </span><span class="reserved-syntax">volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">V</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">LOOP_OVER</span><span class="plain-syntax">(</span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="reserved-syntax">volume</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">V</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">allocation_id</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">; </span><span class="comment-syntax"> placings in WWI are already made</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">E</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">LOOP_OVER</span><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="reserved-syntax">example</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">to_find</span><span class="plain-syntax"> = </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_rubric_pared_down</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">sname</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/2-dct.html#SP10" class="function-link"><span class="function-syntax">Dictionaries::get_text</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">recipe_location</span><span class="plain-syntax">, </span><span class="identifier-syntax">to_find</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">sname</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><a href="../../../inweb/foundation-module/3-em.html#SP7" class="function-link"><span class="function-syntax">Errors::with_text</span></a><span class="plain-syntax">(</span><span class="string-syntax">"recipe book lookup failed (1): %S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">to_find</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">section</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax"> = (</span><span class="reserved-syntax">section</span><span class="plain-syntax"> *) </span><a href="../../../inweb/foundation-module/2-dct.html#SP8" class="function-link"><span class="function-syntax">Dictionaries::read_value</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">V</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">sections_by_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">sname</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">S</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><a href="../../../inweb/foundation-module/3-em.html#SP7" class="function-link"><span class="function-syntax">Errors::with_text</span></a><span class="plain-syntax">(</span>
<span class="plain-syntax"> </span><span class="string-syntax">"recipe book lookup failed: %S refers to nonexistent section"</span><span class="plain-syntax">, </span><span class="identifier-syntax">to_find</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">example_belongs_to_section</span><span class="plain-syntax">[</span><span class="identifier-syntax">V</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">allocation_id</span><span class="plain-syntax">] = </span><span class="identifier-syntax">S</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP4">&#167;4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_4" class="paragraph-anchor"></a><b>&#167;4.4. </b>At this point, then, we know which section every example belongs to. But
we still have to put them in order within those sections: we want 1-star
examples first, then 2-star, and so on. The following does that. In the
@ -410,7 +304,7 @@ inverse permutations.
<p class="commentary firstcommentary"><a id="SP4_5" class="paragraph-anchor"></a><b>&#167;4.5. </b></p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Examples::sort_comparison</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">Examples::sort_comparison</span></span>:<br/><a href="2-exm.html#SP4_4">&#167;4.4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">const</span><span class="plain-syntax"> </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ent1</span><span class="plain-syntax">, </span><span class="reserved-syntax">const</span><span class="plain-syntax"> </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ent2</span><span class="plain-syntax">) {</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Examples::sort_comparison</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">Examples::sort_comparison</span></span>:<br/><a href="2-exm.html#SP4_4">&#167;4.4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">const</span><span class="plain-syntax"> </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ent1</span><span class="plain-syntax">, </span><span class="reserved-syntax">const</span><span class="plain-syntax"> </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ent2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">const</span><span class="plain-syntax"> </span><span class="reserved-syntax">example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">E1</span><span class="plain-syntax"> = *((</span><span class="reserved-syntax">const</span><span class="plain-syntax"> </span><span class="reserved-syntax">example</span><span class="plain-syntax"> **) </span><span class="identifier-syntax">ent1</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">const</span><span class="plain-syntax"> </span><span class="reserved-syntax">example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">E2</span><span class="plain-syntax"> = *((</span><span class="reserved-syntax">const</span><span class="plain-syntax"> </span><span class="reserved-syntax">example</span><span class="plain-syntax"> **) </span><span class="identifier-syntax">ent2</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP20" class="function-link"><span class="function-syntax">Str::cmp</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">E1</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_sort_key</span><span class="plain-syntax">, </span><span class="identifier-syntax">E2</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_sort_key</span><span class="plain-syntax">);</span>
@ -444,7 +338,7 @@ or even the end of the volume, to appear. This is where that's worked out.
<span class="plain-syntax"> }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP4">&#167;4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. Rendering example cues. </b>An example cue is a rendered chunk describing and naming an example. The text
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. Rendering example cues. </b>An example cue is a rendered chunk describing and naming an example. The text
of the example may or may not follow: if it doesn't, the description is a
link which opens it. Depending on the examples mode, the text of the
example may be either (a) included in the file and always visible, (b) included
@ -453,20 +347,20 @@ that is, separate file.
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Examples::render_example_cue</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">Examples::render_example_cue</span></span>:<br/>Renderer - <a href="2-rnd.html#SP8_1_2">&#167;8.1.2</a>, <a href="2-rnd.html#SP14">&#167;14</a><br/>Examples Index - <a href="3-ei.html#SP7">&#167;7</a></span></button><span class="plain-syntax">(</span><span class="constant-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="reserved-syntax">volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">writing_index</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">indoc_settings</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">format</span><span class="plain-syntax"> == </span><span class="constant-syntax">PLAIN_FORMAT</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP7_1" class="named-paragraph-link"><span class="named-paragraph">Render example cue in plain text</span><span class="named-paragraph-number">7.1</span></a></span>
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">indoc_settings</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">format</span><span class="plain-syntax"> == </span><span class="constant-syntax">HTML_FORMAT</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP7_2" class="named-paragraph-link"><span class="named-paragraph">Render example cue in HTML</span><span class="named-paragraph-number">7.2</span></a></span><span class="plain-syntax">;</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Examples::render_example_cue</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">Examples::render_example_cue</span></span>:<br/>Renderer - <a href="2-rnd.html#SP8_1_2">&#167;8.1.2</a>, <a href="2-rnd.html#SP14">&#167;14</a><br/>Examples Index - <a href="3-ei.html#SP7">&#167;7</a></span></button><span class="plain-syntax">(</span><span class="constant-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="reserved-syntax">volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">writing_index</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">indoc_settings</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">format</span><span class="plain-syntax"> == </span><span class="constant-syntax">PLAIN_FORMAT</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP5_1" class="named-paragraph-link"><span class="named-paragraph">Render example cue in plain text</span><span class="named-paragraph-number">5.1</span></a></span>
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">indoc_settings</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">format</span><span class="plain-syntax"> == </span><span class="constant-syntax">HTML_FORMAT</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP5_2" class="named-paragraph-link"><span class="named-paragraph">Render example cue in HTML</span><span class="named-paragraph-number">5.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP7_1" class="paragraph-anchor"></a><b>&#167;7.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Render example cue in plain text</span><span class="named-paragraph-number">7.1</span></span><span class="comment-syntax"> =</span>
<p class="commentary firstcommentary"><a id="SP5_1" class="paragraph-anchor"></a><b>&#167;5.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Render example cue in plain text</span><span class="named-paragraph-number">5.1</span></span><span class="comment-syntax"> =</span>
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"\nExample %d (%S): %S\n%S\n\n"</span><span class="plain-syntax">,</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">example_position</span><span class="plain-syntax">[</span><span class="identifier-syntax">V</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">allocation_id</span><span class="plain-syntax">], </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_stars</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_public_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_outline</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP7">&#167;7</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP7_2" class="paragraph-anchor"></a><b>&#167;7.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Render example cue in HTML</span><span class="named-paragraph-number">7.2</span></span><span class="comment-syntax"> =</span>
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP5">&#167;5</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP5_2" class="paragraph-anchor"></a><b>&#167;5.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Render example cue in HTML</span><span class="named-paragraph-number">5.2</span></span><span class="comment-syntax"> =</span>
</p>
<pre class="displayed-code all-displayed-code code-font">
@ -477,28 +371,28 @@ that is, separate file.
<span class="plain-syntax"> </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">anchor</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">indoc_settings</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">navigation</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">simplified_examples</span><span class="plain-syntax"> == </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP7_2_1" class="named-paragraph-link"><span class="named-paragraph">Render the example cue left surround</span><span class="named-paragraph-number">7.2.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">indoc_settings</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">navigation</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">simplified_examples</span><span class="plain-syntax"> == </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP5_2_1" class="named-paragraph-link"><span class="named-paragraph">Render the example cue left surround</span><span class="named-paragraph-number">5.2.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">url</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">onclick</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><a href="2-exm.html#SP8" class="function-link"><span class="function-syntax">Examples::open_example_url</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">url</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="identifier-syntax">writing_index</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="2-exm.html#SP9" class="function-link"><span class="function-syntax">Examples::open_example_onclick</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">onclick</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="identifier-syntax">writing_index</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="2-exm.html#SP6" class="function-link"><span class="function-syntax">Examples::open_example_url</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">url</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="identifier-syntax">writing_index</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="2-exm.html#SP7" class="function-link"><span class="function-syntax">Examples::open_example_onclick</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">onclick</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="identifier-syntax">writing_index</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/5-htm.html#SP17" class="function-link"><span class="function-syntax">HTML::begin_link_with_class_onclick</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"eglink"</span><span class="plain-syntax">, </span><span class="identifier-syntax">url</span><span class="plain-syntax">, </span><span class="identifier-syntax">onclick</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">url</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">onclick</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP7_2_2" class="named-paragraph-link"><span class="named-paragraph">Render the example difficulty asterisks</span><span class="named-paragraph-number">7.2.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP7_2_3" class="named-paragraph-link"><span class="named-paragraph">Render the example name</span><span class="named-paragraph-number">7.2.3</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP5_2_2" class="named-paragraph-link"><span class="named-paragraph">Render the example difficulty asterisks</span><span class="named-paragraph-number">5.2.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP5_2_3" class="named-paragraph-link"><span class="named-paragraph">Render the example name</span><span class="named-paragraph-number">5.2.3</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/5-htm.html#SP17" class="function-link"><span class="function-syntax">HTML::end_link</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">HTML_TAG</span><span class="plain-syntax">(</span><span class="string-syntax">"br"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_outline</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">indoc_settings</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">navigation</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">simplified_examples</span><span class="plain-syntax"> == </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP7_2_4" class="named-paragraph-link"><span class="named-paragraph">Render the example cue right surround</span><span class="named-paragraph-number">7.2.4</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">indoc_settings</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">navigation</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">simplified_examples</span><span class="plain-syntax"> == </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP5_2_4" class="named-paragraph-link"><span class="named-paragraph">Render the example cue right surround</span><span class="named-paragraph-number">5.2.4</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"\n"</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP7">&#167;7</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP7_2_1" class="paragraph-anchor"></a><b>&#167;7.2.1. </b>The "surround" is an table-implemented area which contains the descriptive
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP5">&#167;5</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP5_2_1" class="paragraph-anchor"></a><b>&#167;5.2.1. </b>The "surround" is an table-implemented area which contains the descriptive
panel about the example. It has one row of three cells:
</p>
@ -510,7 +404,7 @@ example, including its name; and the cross-link to the same example in the
other book.
</p>
<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Render the example cue left surround</span><span class="named-paragraph-number">7.2.1</span></span><span class="comment-syntax"> =</span>
<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Render the example cue left surround</span><span class="named-paragraph-number">5.2.1</span></span><span class="comment-syntax"> =</span>
</p>
<pre class="displayed-code all-displayed-code code-font">
@ -521,8 +415,8 @@ other book.
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/5-htm.html#SP14" class="function-link"><span class="function-syntax">HTML::begin_div_with_class_S</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"egovalfornumber overstruckimage"</span><span class="plain-syntax">, </span><span class="identifier-syntax">__FILE__</span><span class="plain-syntax">, </span><span class="identifier-syntax">__LINE__</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">url</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">onclick</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><a href="2-exm.html#SP8" class="function-link"><span class="function-syntax">Examples::open_example_url</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">url</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="identifier-syntax">writing_index</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="2-exm.html#SP9" class="function-link"><span class="function-syntax">Examples::open_example_onclick</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">onclick</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="identifier-syntax">writing_index</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="2-exm.html#SP6" class="function-link"><span class="function-syntax">Examples::open_example_url</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">url</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="identifier-syntax">writing_index</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="2-exm.html#SP7" class="function-link"><span class="function-syntax">Examples::open_example_onclick</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">onclick</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="identifier-syntax">writing_index</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/5-htm.html#SP17" class="function-link"><span class="function-syntax">HTML::begin_link_with_class_onclick</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"eglink"</span><span class="plain-syntax">, </span><span class="identifier-syntax">url</span><span class="plain-syntax">, </span><span class="identifier-syntax">onclick</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">url</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">onclick</span><span class="plain-syntax">)</span>
@ -534,8 +428,8 @@ other book.
<span class="plain-syntax"> </span><span class="identifier-syntax">HTML_OPEN_WITH</span><span class="plain-syntax">(</span><span class="string-syntax">"td"</span><span class="plain-syntax">, </span><span class="string-syntax">"class=\"egnamecell\""</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">HTML_OPEN_WITH</span><span class="plain-syntax">(</span><span class="string-syntax">"p"</span><span class="plain-syntax">, </span><span class="string-syntax">"class=\"egcuetext\""</span><span class="plain-syntax">); </span><span class="comment-syntax"> The Descriptive Panel Area begins</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP7_2">&#167;7.2</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP7_2_2" class="paragraph-anchor"></a><b>&#167;7.2.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Render the example difficulty asterisks</span><span class="named-paragraph-number">7.2.2</span></span><span class="comment-syntax"> =</span>
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP5_2">&#167;5.2</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP5_2_2" class="paragraph-anchor"></a><b>&#167;5.2.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Render the example difficulty asterisks</span><span class="named-paragraph-number">5.2.2</span></span><span class="comment-syntax"> =</span>
</p>
<pre class="displayed-code all-displayed-code code-font">
@ -544,20 +438,14 @@ other book.
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><a href="2-haj.html#SP12" class="function-link"><span class="function-syntax">HTMLUtilities::asterisk_image</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"asterisk.png"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP7_2">&#167;7.2</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP7_2_3" class="paragraph-anchor"></a><b>&#167;7.2.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Render the example name</span><span class="named-paragraph-number">7.2.3</span></span><span class="comment-syntax"> =</span>
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP5_2">&#167;5.2</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP5_2_3" class="paragraph-anchor"></a><b>&#167;5.2.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Render the example name</span><span class="named-paragraph-number">5.2.3</span></span><span class="comment-syntax"> =</span>
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax"> </span><span class="identifier-syntax">HTML_OPEN</span><span class="plain-syntax">(</span><span class="string-syntax">"b"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">text_of_name</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">text_of_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_rubric</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">match_results</span><span class="plain-syntax"> </span><span class="identifier-syntax">mr</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/4-pm.html#SP9" class="function-link"><span class="function-syntax">Regexp::create_mr</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-pm.html#SP10" class="function-link"><span class="function-syntax">Regexp::match</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_of_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"%c*;(%c*?)"</span><span class="plain-syntax">)) </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">text_of_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-pm.html#SP10" class="function-link"><span class="function-syntax">Regexp::match</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_of_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"(%c*?): (%d+)%c*"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP15" class="function-link"><span class="function-syntax">Str::clear</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">text_of_name</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">text_of_name</span><span class="plain-syntax">, </span><span class="string-syntax">"%S %S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[0], </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">text_of_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_public_name</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP24" class="function-link"><span class="function-syntax">Str::trim_white_space</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">text_of_name</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="2-rr.html#SP5" class="function-link"><span class="function-syntax">Rawtext::escape_HTML_characters_in</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">text_of_name</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">indoc_settings</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">navigation</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">simplified_examples</span><span class="plain-syntax"> == </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">) {</span>
@ -571,11 +459,10 @@ other book.
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"Example %d: %S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">example_position</span><span class="plain-syntax">[0], </span><span class="identifier-syntax">text_of_name</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">text_of_name</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-pm.html#SP9" class="function-link"><span class="function-syntax">Regexp::dispose_of</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">HTML_CLOSE</span><span class="plain-syntax">(</span><span class="string-syntax">"b"</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP7_2">&#167;7.2</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP7_2_4" class="paragraph-anchor"></a><b>&#167;7.2.4. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Render the example cue right surround</span><span class="named-paragraph-number">7.2.4</span></span><span class="comment-syntax"> =</span>
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP5_2">&#167;5.2</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP5_2_4" class="paragraph-anchor"></a><b>&#167;5.2.4. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Render the example cue right surround</span><span class="named-paragraph-number">5.2.4</span></span><span class="comment-syntax"> =</span>
</p>
<pre class="displayed-code all-displayed-code code-font">
@ -583,13 +470,13 @@ other book.
<span class="plain-syntax"> </span><span class="identifier-syntax">HTML_CLOSE</span><span class="plain-syntax">(</span><span class="string-syntax">"td"</span><span class="plain-syntax">); </span><span class="comment-syntax"> The Descriptive Panel Area ends</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">HTML_OPEN_WITH</span><span class="plain-syntax">(</span><span class="string-syntax">"td"</span><span class="plain-syntax">, </span><span class="string-syntax">"class=\"egcrossref\""</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">no_volumes</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">1</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP7_2_4_1" class="named-paragraph-link"><span class="named-paragraph">Render the cross-link to the same example in the other book</span><span class="named-paragraph-number">7.2.4.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="2-exm.html#SP5_2_4_1" class="named-paragraph-link"><span class="named-paragraph">Render the cross-link to the same example in the other book</span><span class="named-paragraph-number">5.2.4.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">HTML_CLOSE</span><span class="plain-syntax">(</span><span class="string-syntax">"td"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">HTML_CLOSE</span><span class="plain-syntax">(</span><span class="string-syntax">"tr"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">HTML_CLOSE</span><span class="plain-syntax">(</span><span class="string-syntax">"table"</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP7_2">&#167;7.2</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP7_2_4_1" class="paragraph-anchor"></a><b>&#167;7.2.4.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Render the cross-link to the same example in the other book</span><span class="named-paragraph-number">7.2.4.1</span></span><span class="comment-syntax"> =</span>
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP5_2">&#167;5.2</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP5_2_4_1" class="paragraph-anchor"></a><b>&#167;5.2.4.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Render the cross-link to the same example in the other book</span><span class="named-paragraph-number">5.2.4.1</span></span><span class="comment-syntax"> =</span>
</p>
<pre class="displayed-code all-displayed-code code-font">
@ -598,31 +485,31 @@ other book.
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/5-htm.html#SP22" class="function-link"><span class="function-syntax">HTML::comment</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"START IGNORE"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/5-htm.html#SP14" class="function-link"><span class="function-syntax">HTML::begin_div_with_class_S</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"egovalforxref overstruckimage"</span><span class="plain-syntax">, </span><span class="identifier-syntax">__FILE__</span><span class="plain-syntax">, </span><span class="identifier-syntax">__LINE__</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">url</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><a href="2-exm.html#SP8" class="function-link"><span class="function-syntax">Examples::open_example_url</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">url</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="identifier-syntax">V_to</span><span class="plain-syntax">, </span><span class="identifier-syntax">writing_index</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="2-exm.html#SP6" class="function-link"><span class="function-syntax">Examples::open_example_url</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">url</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="identifier-syntax">V_to</span><span class="plain-syntax">, </span><span class="identifier-syntax">writing_index</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/5-htm.html#SP17" class="function-link"><span class="function-syntax">HTML::begin_link</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">url</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;i&gt;%s&lt;/i&gt;"</span><span class="plain-syntax">, </span><span class="identifier-syntax">cross_to</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/5-htm.html#SP17" class="function-link"><span class="function-syntax">HTML::end_link</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/5-htm.html#SP14" class="function-link"><span class="function-syntax">HTML::end_div</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/5-htm.html#SP22" class="function-link"><span class="function-syntax">HTML::comment</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"END IGNORE"</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP7_2_4">&#167;7.2.4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. </b>The following is a URL for a link which opens the example. Note that in
<ul class="endnotetexts"><li>This code is used in <a href="2-exm.html#SP5_2_4">&#167;5.2.4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. </b>The following is a URL for a link which opens the example. Note that in
some cases this should work by a Javascript function call instead...
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Examples::open_example_url</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">Examples::open_example_url</span></span>:<br/><a href="2-exm.html#SP7_2">&#167;7.2</a>, <a href="2-exm.html#SP7_2_1">&#167;7.2.1</a>, <a href="2-exm.html#SP7_2_4_1">&#167;7.2.4.1</a></span></button><span class="plain-syntax">(</span><span class="constant-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="reserved-syntax">volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">from_V</span><span class="plain-syntax">, </span><span class="reserved-syntax">volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">writing_index</span><span class="plain-syntax">) {</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Examples::open_example_url</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">Examples::open_example_url</span></span>:<br/><a href="2-exm.html#SP5_2">&#167;5.2</a>, <a href="2-exm.html#SP5_2_1">&#167;5.2.1</a>, <a href="2-exm.html#SP5_2_4_1">&#167;5.2.4.1</a></span></button><span class="plain-syntax">(</span><span class="constant-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="reserved-syntax">volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">from_V</span><span class="plain-syntax">, </span><span class="reserved-syntax">volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">writing_index</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">indoc_settings</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">examples_mode</span><span class="plain-syntax"> == </span><span class="constant-syntax">EXMODE_openable_internal</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">writing_index</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">from_V</span><span class="plain-syntax"> == </span><span class="identifier-syntax">V</span><span class="plain-syntax">))</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"#"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span>
<span class="plain-syntax"> </span><a href="2-exm.html#SP10" class="function-link"><span class="function-syntax">Examples::goto_example_url</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="2-exm.html#SP8" class="function-link"><span class="function-syntax">Examples::goto_example_url</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. </b>...and this is it, used for the <span class="extract"><span class="extract-syntax">onclick</span></span> field:
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. </b>...and this is it, used for the <span class="extract"><span class="extract-syntax">onclick</span></span> field:
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Examples::open_example_onclick</span><button class="popup" onclick="togglePopup('usagePopup7')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup7">Usage of <span class="code-font"><span class="function-syntax">Examples::open_example_onclick</span></span>:<br/><a href="2-exm.html#SP7_2">&#167;7.2</a>, <a href="2-exm.html#SP7_2_1">&#167;7.2.1</a></span></button><span class="plain-syntax">(</span><span class="constant-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="reserved-syntax">volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">from_V</span><span class="plain-syntax">, </span><span class="reserved-syntax">volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">writing_index</span><span class="plain-syntax">) {</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Examples::open_example_onclick</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">Examples::open_example_onclick</span></span>:<br/><a href="2-exm.html#SP5_2">&#167;5.2</a>, <a href="2-exm.html#SP5_2_1">&#167;5.2.1</a></span></button><span class="plain-syntax">(</span><span class="constant-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="reserved-syntax">volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">from_V</span><span class="plain-syntax">, </span><span class="reserved-syntax">volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">writing_index</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">indoc_settings</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">examples_mode</span><span class="plain-syntax"> == </span><span class="constant-syntax">EXMODE_openable_internal</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax"> (</span><span class="identifier-syntax">writing_index</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax"> (</span><span class="identifier-syntax">from_V</span><span class="plain-syntax"> == </span><span class="identifier-syntax">V</span><span class="plain-syntax">)) {</span>
@ -630,11 +517,11 @@ some cases this should work by a Javascript function call instead...
<span class="plain-syntax"> }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP10" class="paragraph-anchor"></a><b>&#167;10. </b>The actual URL holding the contents of an example are as follows:
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. </b>The actual URL holding the contents of an example are as follows:
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Examples::goto_example_url</span><button class="popup" onclick="togglePopup('usagePopup8')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup8">Usage of <span class="code-font"><span class="function-syntax">Examples::goto_example_url</span></span>:<br/><a href="2-exm.html#SP8">&#167;8</a><br/>Examples Index - <a href="3-ei.html#SP3_2">&#167;3.2</a><br/>Codename Roadsign - <a href="4-cr.html#SP6_2">&#167;6.2</a></span></button><span class="plain-syntax">(</span><span class="constant-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="reserved-syntax">volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">V</span><span class="plain-syntax">) {</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Examples::goto_example_url</span><button class="popup" onclick="togglePopup('usagePopup7')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup7">Usage of <span class="code-font"><span class="function-syntax">Examples::goto_example_url</span></span>:<br/><a href="2-exm.html#SP6">&#167;6</a><br/>Examples Index - <a href="3-ei.html#SP3_2">&#167;3.2</a><br/>Codename Roadsign - <a href="4-cr.html#SP6_2">&#167;6.2</a></span></button><span class="plain-syntax">(</span><span class="constant-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="reserved-syntax">volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">V</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"%S#e%d"</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">example_belongs_to_section</span><span class="plain-syntax">[</span><span class="identifier-syntax">V</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">allocation_id</span><span class="plain-syntax">]-&gt;</span><span class="element-syntax">unanchored_URL</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">allocation_id</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>

View file

@ -268,7 +268,7 @@ working backwards. As soon as we find a file of that name, we copy it over.
<span class="plain-syntax"> </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">details</span><span class="plain-syntax">)</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">HTMLUtilities::asterisk_image</span><button class="popup" onclick="togglePopup('usagePopup13')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup13">Usage of <span class="code-font"><span class="function-syntax">HTMLUtilities::asterisk_image</span></span>:<br/>Examples - <a href="2-exm.html#SP7_2_2">&#167;7.2.2</a><br/>Renderer - <a href="2-rnd.html#SP13">&#167;13</a><br/>Codename Roadsign - <a href="4-cr.html#SP6_2">&#167;6.2</a></span></button><span class="plain-syntax">(</span><span class="constant-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">name</span><span class="plain-syntax">) {</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">HTMLUtilities::asterisk_image</span><button class="popup" onclick="togglePopup('usagePopup13')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup13">Usage of <span class="code-font"><span class="function-syntax">HTMLUtilities::asterisk_image</span></span>:<br/>Examples - <a href="2-exm.html#SP5_2_2">&#167;5.2.2</a><br/>Renderer - <a href="2-rnd.html#SP13">&#167;13</a><br/>Codename Roadsign - <a href="4-cr.html#SP6_2">&#167;6.2</a></span></button><span class="plain-syntax">(</span><span class="constant-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">name</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">details</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">details</span><span class="plain-syntax">, </span><span class="string-syntax">"class=\"asterisk\" alt=\"*\" src=\""</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="2-haj.html#SP3" class="function-link"><span class="function-syntax">HTMLUtilities::image_URL</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">details</span><span class="plain-syntax">, </span><span class="identifier-syntax">name</span><span class="plain-syntax">);</span>

View file

@ -219,7 +219,7 @@ section names are capitalised for this purpose.)
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/5-htm.html#SP22" class="function-link"><span class="function-syntax">HTML::comment</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">comment</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">comment</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><a href="2-exm.html#SP7" class="function-link"><span class="function-syntax">Examples::render_example_cue</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="2-exm.html#SP5" class="function-link"><span class="function-syntax">Examples::render_example_cue</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">code_example</span><span class="plain-syntax"> = </span><span class="identifier-syntax">E</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">OUT</span><span class="plain-syntax"> = </span><a href="2-rnd.html#SP9" class="function-link"><span class="function-syntax">Renderer::render_example_body</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="constant-syntax">TRUE</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">code_example</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
@ -382,7 +382,7 @@ very much.
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">index_to_examples</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-pm.html#SP10" class="function-link"><span class="function-syntax">Regexp::match</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">raw</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"{%*}&amp;quot;(%c*)&amp;quot;%c*"</span><span class="plain-syntax">)) &amp;&amp;</span>
<span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP22" class="function-link"><span class="function-syntax">Str::ne_wide_string</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[0], </span><span class="identifier-syntax">L</span><span class="string-syntax">"Midsummer Day"</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax"> </span><a href="3-ei.html#SP2" class="function-link"><span class="function-syntax">ExamplesIndex::add_to_alphabetic_examples_index</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[0], </span><span class="identifier-syntax">S</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="constant-syntax">TRUE</span><span class="plain-syntax">, </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="3-ei.html#SP2" class="function-link"><span class="function-syntax">ExamplesIndex::add_to_alphabetic_examples_index</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[0], </span><span class="identifier-syntax">S</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="constant-syntax">TRUE</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-pm.html#SP9" class="function-link"><span class="function-syntax">Regexp::dispose_of</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> }</span>
</pre>
@ -798,7 +798,7 @@ which block is meant, and encode this as a link.
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Renderer::render_example_cross_reference</span><button class="popup" onclick="togglePopup('usagePopup8')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup8">Usage of <span class="code-font"><span class="function-syntax">Renderer::render_example_cross_reference</span></span>:<br/><a href="2-rnd.html#SP10_2_7">&#167;10.2.7</a></span></button><span class="plain-syntax">(</span><span class="constant-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ename</span><span class="plain-syntax">, </span><span class="reserved-syntax">volume</span><span class="plain-syntax"> *</span><span class="identifier-syntax">V</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">E</span><span class="plain-syntax"> = (</span><span class="reserved-syntax">example</span><span class="plain-syntax"> *) </span><a href="../../../inweb/foundation-module/2-dct.html#SP8" class="function-link"><span class="function-syntax">Dictionaries::read_value</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">examples_by_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">ename</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">E</span><span class="plain-syntax">) </span><a href="2-exm.html#SP7" class="function-link"><span class="function-syntax">Examples::render_example_cue</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">E</span><span class="plain-syntax">) </span><a href="2-exm.html#SP5" class="function-link"><span class="function-syntax">Examples::render_example_cue</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/3-em.html#SP7" class="function-link"><span class="function-syntax">Errors::with_text</span></a><span class="plain-syntax">(</span><span class="string-syntax">"cross-reference to %S points to no section"</span><span class="plain-syntax">, </span><span class="identifier-syntax">ename</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

View file

@ -118,7 +118,7 @@ must be. (A block ends when a new heading line appears, or at end of file.)
<span class="plain-syntax"> </span><span class="identifier-syntax">rhs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">no_blocks_read_in_current_chapter</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">rhs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">no_pars_read_in_current_block</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">rhs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">title_of_block_being_read</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/4-sm.html#SP2" class="function-link"><span class="function-syntax">Str::new</span></a><span class="plain-syntax">(); </span><span class="comment-syntax"> Untitled until a block heading found</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">E</span><span class="plain-syntax">) </span><span class="identifier-syntax">rhs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">skip_opening_lines</span><span class="plain-syntax"> = </span><span class="constant-syntax">3</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">E</span><span class="plain-syntax">) </span><span class="identifier-syntax">rhs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">skip_opening_lines</span><span class="plain-syntax"> = </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_header_length</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">rhs</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">skip_opening_lines</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="2-rr.html#SP3_1" class="named-paragraph-link"><span class="named-paragraph">Prepare to read a new chapter of rawtext</span><span class="named-paragraph-number">3.1</span></a></span><span class="plain-syntax">;</span>
@ -566,7 +566,7 @@ in tag elements into <span class="extract"><span class="extract-syntax">&amp;quo
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. </b></p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Rawtext::escape_HTML_characters_in</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">Rawtext::escape_HTML_characters_in</span></span>:<br/><a href="2-rr.html#SP4_7_2">&#167;4.7.2</a><br/>Examples - <a href="2-exm.html#SP7_2_3">&#167;7.2.3</a><br/>Contents and Indexes - <a href="3-gi.html#SP9_2_3_1">&#167;9.2.3.1</a><br/>Examples Index - <a href="3-ei.html#SP3_5">&#167;3.5</a><br/>Codename Roadsign - <a href="4-cr.html#SP6_2">&#167;6.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">text</span><span class="plain-syntax">) {</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Rawtext::escape_HTML_characters_in</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">Rawtext::escape_HTML_characters_in</span></span>:<br/><a href="2-rr.html#SP4_7_2">&#167;4.7.2</a><br/>Examples - <a href="2-exm.html#SP5_2_3">&#167;5.2.3</a><br/>Contents and Indexes - <a href="3-gi.html#SP9_2_3_1">&#167;9.2.3.1</a><br/>Examples Index - <a href="3-ei.html#SP3_5">&#167;3.5</a><br/>Codename Roadsign - <a href="4-cr.html#SP6_2">&#167;6.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">text</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">indoc_settings</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">format</span><span class="plain-syntax"> == </span><span class="constant-syntax">HTML_FORMAT</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">modified</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">=0, </span><span class="identifier-syntax">L</span><span class="plain-syntax">=</span><a href="../../../inweb/foundation-module/4-sm.html#SP8" class="function-link"><span class="function-syntax">Str::len</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">text</span><span class="plain-syntax">); </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">L</span><span class="plain-syntax">; </span><span class="identifier-syntax">i</span><span class="plain-syntax">++) {</span>

View file

@ -87,65 +87,17 @@ also appear here. So we actually maintain an alphabetical index able to
index examples under arbitrary, multiple descriptions.
</p>
<p class="commentary">If this is called with the <span class="extract"><span class="extract-syntax">RB_flag</span></span> set, then it adds the entry to the
thematic index instead, which shares code here because it also involves a
degree of alphabetisation.
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">ExamplesIndex::add_to_alphabetic_examples_index</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">ExamplesIndex::add_to_alphabetic_examples_index</span></span>:<br/><a href="3-ei.html#SP3_1">&#167;3.1</a><br/>Renderer - <a href="2-rnd.html#SP10_2_2_2">&#167;10.2.2.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">given_rubric</span><span class="plain-syntax">,</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">section</span><span class="plain-syntax"> *</span><span class="identifier-syntax">index_to_S</span><span class="plain-syntax">, </span><span class="reserved-syntax">example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">index_to_E</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">bold_flag</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">RB_flag</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">rubric</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">rubric</span><span class="plain-syntax">, </span><span class="identifier-syntax">given_rubric</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">match_results</span><span class="plain-syntax"> </span><span class="identifier-syntax">mr</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/4-pm.html#SP9" class="function-link"><span class="function-syntax">Regexp::create_mr</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-pm.html#SP10" class="function-link"><span class="function-syntax">Regexp::match</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">rubric</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"(%c*); *(%c*?)"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax"> </span><a href="3-ei.html#SP2" class="function-link"><span class="function-syntax">ExamplesIndex::add_to_alphabetic_examples_index</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[0], </span><span class="identifier-syntax">index_to_S</span><span class="plain-syntax">, </span><span class="identifier-syntax">index_to_E</span><span class="plain-syntax">, </span><span class="identifier-syntax">bold_flag</span><span class="plain-syntax">, </span><span class="identifier-syntax">RB_flag</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="3-ei.html#SP2" class="function-link"><span class="function-syntax">ExamplesIndex::add_to_alphabetic_examples_index</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[1], </span><span class="identifier-syntax">index_to_S</span><span class="plain-syntax">, </span><span class="identifier-syntax">index_to_E</span><span class="plain-syntax">, </span><span class="constant-syntax">TRUE</span><span class="plain-syntax">, </span><span class="identifier-syntax">RB_flag</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">RB_flag</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="3-ei.html#SP2_1" class="named-paragraph-link"><span class="named-paragraph">Translate the rubric according to the Recipe Book catalogue</span><span class="named-paragraph-number">2.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="3-ei.html#SP2_2" class="named-paragraph-link"><span class="named-paragraph">Add a single new term to the examples index</span><span class="named-paragraph-number">2.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-pm.html#SP9" class="function-link"><span class="function-syntax">Regexp::dispose_of</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">rubric</span><span class="plain-syntax">)</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP2_1" class="paragraph-anchor"></a><b>&#167;2.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Translate the rubric according to the Recipe Book catalogue</span><span class="named-paragraph-number">2.1</span></span><span class="comment-syntax"> =</span>
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">trans</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/2-dct.html#SP10" class="function-link"><span class="function-syntax">Dictionaries::get_text</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">recipe_translates_as</span><span class="plain-syntax">, </span><span class="identifier-syntax">rubric</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP8" class="function-link"><span class="function-syntax">Str::len</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">trans</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP19" class="function-link"><span class="function-syntax">Str::eq</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">trans</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"OMIT"</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">rubric</span><span class="plain-syntax">, </span><span class="identifier-syntax">trans</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="3-ei.html#SP2">&#167;2</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP2_2" class="paragraph-anchor"></a><b>&#167;2.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Add a single new term to the examples index</span><span class="named-paragraph-number">2.2</span></span><span class="comment-syntax"> =</span>
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax"> </span><span class="reserved-syntax">section</span><span class="plain-syntax"> *</span><span class="identifier-syntax">index_to_S</span><span class="plain-syntax">, </span><span class="reserved-syntax">example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">index_to_E</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">bold_flag</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">sort_key</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">subtitle</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">sort_key</span><span class="plain-syntax">, </span><span class="identifier-syntax">rubric</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-pm.html#SP10" class="function-link"><span class="function-syntax">Regexp::match</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">rubric</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"(%c*?) *-- *(%c*)"</span><span class="plain-syntax">)) </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">rubric</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-pm.html#SP10" class="function-link"><span class="function-syntax">Regexp::match</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">rubric</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">"(%c*?): *(%c*?)"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">rubric</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">subtitle</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">sort_key</span><span class="plain-syntax">, </span><span class="identifier-syntax">given_rubric</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="3-iu.html#SP3" class="function-link"><span class="function-syntax">IndexUtilities::improve_alphabetisation</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">sort_key</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">RB_flag</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pre</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/2-dct.html#SP10" class="function-link"><span class="function-syntax">Dictionaries::get_text</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">recipe_sort_prefix</span><span class="plain-syntax">, </span><span class="identifier-syntax">rubric</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP8" class="function-link"><span class="function-syntax">Str::len</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">pre</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">p</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">p</span><span class="plain-syntax">, </span><span class="string-syntax">"%S&gt;%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">pre</span><span class="plain-syntax">, </span><span class="identifier-syntax">sort_key</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">sort_key</span><span class="plain-syntax">, </span><span class="identifier-syntax">p</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">p</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">example_index_data</span><span class="plain-syntax"> *</span><span class="identifier-syntax">eid</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">example_index_data</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">eid</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">alpha_index_embolden</span><span class="plain-syntax"> = </span><span class="identifier-syntax">bold_flag</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">eid</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">alpha_index_rubric</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/4-sm.html#SP3" class="function-link"><span class="function-syntax">Str::duplicate</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">rubric</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">eid</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">alpha_index_rubric</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/4-sm.html#SP3" class="function-link"><span class="function-syntax">Str::duplicate</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">given_rubric</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">eid</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">alpha_index_subtitle</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/4-sm.html#SP3" class="function-link"><span class="function-syntax">Str::duplicate</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">subtitle</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">eid</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">alpha_index_to_S</span><span class="plain-syntax"> = </span><span class="identifier-syntax">index_to_S</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">eid</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">alpha_index_to_E</span><span class="plain-syntax"> = </span><span class="identifier-syntax">index_to_E</span><span class="plain-syntax">;</span>
@ -155,8 +107,8 @@ degree of alphabetisation.
<span class="plain-syntax"> </span><span class="identifier-syntax">example_index_data_by_rubric</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/2-dct.html#SP2" class="function-link"><span class="function-syntax">Dictionaries::new</span></a><span class="plain-syntax">(100, </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/2-dct.html#SP5" class="function-link"><span class="function-syntax">Dictionaries::create</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">example_index_data_by_rubric</span><span class="plain-syntax">, </span><span class="identifier-syntax">sort_key</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/2-dct.html#SP8" class="function-link"><span class="function-syntax">Dictionaries::write_value</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">example_index_data_by_rubric</span><span class="plain-syntax">, </span><span class="identifier-syntax">sort_key</span><span class="plain-syntax">, (</span><span class="reserved-syntax">void</span><span class="plain-syntax"> *) </span><span class="identifier-syntax">eid</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="3-ei.html#SP2">&#167;2</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. Alphabetic index of examples. </b></p>
<pre class="displayed-code all-displayed-code code-font">
@ -203,8 +155,20 @@ degree of alphabetisation.
<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax"> </span><span class="reserved-syntax">example</span><span class="plain-syntax"> *</span><span class="identifier-syntax">E</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">LOOP_OVER</span><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="reserved-syntax">example</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><a href="3-ei.html#SP2" class="function-link"><span class="function-syntax">ExamplesIndex::add_to_alphabetic_examples_index</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_rubric</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">, </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">LOOP_OVER</span><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="reserved-syntax">example</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP8" class="function-link"><span class="function-syntax">Str::len</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_subtitle</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">index_as</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">index_as</span><span class="plain-syntax">, </span><span class="string-syntax">"%S: %S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_public_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_subtitle</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="3-ei.html#SP2" class="function-link"><span class="function-syntax">ExamplesIndex::add_to_alphabetic_examples_index</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">index_as</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="constant-syntax">TRUE</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">index_as</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP19" class="function-link"><span class="function-syntax">Str::eq</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_index</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_public_name</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax"> </span><a href="3-ei.html#SP2" class="function-link"><span class="function-syntax">ExamplesIndex::add_to_alphabetic_examples_index</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_index</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><a href="3-ei.html#SP2" class="function-link"><span class="function-syntax">ExamplesIndex::add_to_alphabetic_examples_index</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_public_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="constant-syntax">TRUE</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP8" class="function-link"><span class="function-syntax">Str::len</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_index</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><a href="3-ei.html#SP2" class="function-link"><span class="function-syntax">ExamplesIndex::add_to_alphabetic_examples_index</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_index</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="3-ei.html#SP3">&#167;3</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP3_2" class="paragraph-anchor"></a><b>&#167;3.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Work out the URL of this example</span><span class="named-paragraph-number">3.2</span></span><span class="comment-syntax"> =</span>
@ -214,7 +178,7 @@ degree of alphabetisation.
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">eid</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">alpha_index_to_S</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">url</span><span class="plain-syntax">, </span><span class="string-syntax">"%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">eid</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">alpha_index_to_S</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">section_URL</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span>
<span class="plain-syntax"> </span><a href="2-exm.html#SP10" class="function-link"><span class="function-syntax">Examples::goto_example_url</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">url</span><span class="plain-syntax">, </span><span class="identifier-syntax">eid</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">alpha_index_to_E</span><span class="plain-syntax">, </span><span class="identifier-syntax">volumes</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax"> </span><a href="2-exm.html#SP8" class="function-link"><span class="function-syntax">Examples::goto_example_url</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">url</span><span class="plain-syntax">, </span><span class="identifier-syntax">eid</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">alpha_index_to_E</span><span class="plain-syntax">, </span><span class="identifier-syntax">volumes</span><span class="plain-syntax">[0]);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="3-ei.html#SP3">&#167;3</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP3_3" class="paragraph-anchor"></a><b>&#167;3.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Start a new letter block</span><span class="named-paragraph-number">3.3</span></span><span class="comment-syntax"> =</span>
@ -321,7 +285,7 @@ degree of alphabetisation.
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;i&gt;%c%S&lt;/i&gt;"</span><span class="plain-syntax">, </span><span class="constant-syntax">SECTION_SYMBOL</span><span class="plain-syntax">, </span><span class="identifier-syntax">S</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">title</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">HTML_CLOSE</span><span class="plain-syntax">(</span><span class="string-syntax">"p"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><a href="2-exm.html#SP7" class="function-link"><span class="function-syntax">Examples::render_example_cue</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="constant-syntax">TRUE</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="2-exm.html#SP5" class="function-link"><span class="function-syntax">Examples::render_example_cue</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">, </span><span class="constant-syntax">TRUE</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax">}</span>
</pre>

View file

@ -125,7 +125,7 @@ alphabetical sorting will agree with numerical.
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">val</span><span class="plain-syntax">, </span><span class="identifier-syntax">alphabetise_as</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">IndexUtilities::improve_alphabetisation</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">IndexUtilities::improve_alphabetisation</span></span>:<br/>Contents and Indexes - <a href="3-gi.html#SP9_1">&#167;9.1</a><br/>Examples Index - <a href="3-ei.html#SP2_2">&#167;2.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">sort_key</span><span class="plain-syntax">) {</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">IndexUtilities::improve_alphabetisation</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">IndexUtilities::improve_alphabetisation</span></span>:<br/>Contents and Indexes - <a href="3-gi.html#SP9_1">&#167;9.1</a><br/>Examples Index - <a href="3-ei.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">sort_key</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">alph</span><span class="plain-syntax"> = </span><a href="../../../inweb/foundation-module/2-dct.html#SP10" class="function-link"><span class="function-syntax">Dictionaries::get_text</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">alphabetisation_exceptions</span><span class="plain-syntax">, </span><span class="identifier-syntax">sort_key</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../../../inweb/foundation-module/4-sm.html#SP8" class="function-link"><span class="function-syntax">Str::len</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">alph</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><a href="../../../inweb/foundation-module/4-sm.html#SP17" class="function-link"><span class="function-syntax">Str::copy</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">sort_key</span><span class="plain-syntax">, </span><span class="identifier-syntax">alph</span><span class="plain-syntax">);</span>

View file

@ -328,7 +328,7 @@ function togglePopup(material_id) {
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">text</span><span class="plain-syntax">, </span><span class="string-syntax">"Example %d: %S &lt;b&gt;%S&lt;/b&gt;&amp;#160;&amp;#160;&amp;#160; %S"</span><span class="plain-syntax">,</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">example_position</span><span class="plain-syntax">[0], </span><span class="identifier-syntax">stars</span><span class="plain-syntax">, </span><span class="identifier-syntax">pn</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">ex_outline</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">url</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><a href="2-exm.html#SP10" class="function-link"><span class="function-syntax">Examples::goto_example_url</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">url</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="2-exm.html#SP8" class="function-link"><span class="function-syntax">Examples::goto_example_url</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">url</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">V</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="4-cr.html#SP10" class="function-link"><span class="function-syntax">Roadsign::roadsign_add_direction</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">OUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"arrow-down.png"</span><span class="plain-syntax">, </span><span class="identifier-syntax">text</span><span class="plain-syntax">, </span><span class="identifier-syntax">url</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">text</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">stars</span><span class="plain-syntax">)</span>

View file

@ -128,7 +128,7 @@ function togglePopup(material_id) {
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>The structure navigation_design is accessed in 2/mth, 2/exm, 3/iu, 4/cm, 4/ca, 4/ct and here.</li></ul>
<ul class="endnotetexts"><li>The structure navigation_design is accessed in 2/mth, 9/pl, 2/exm, 3/iu, 4/cm, 4/ca, 4/ct and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. Top. </b>At the front end of a section, before any of its text.
</p>

View file

@ -64,7 +64,7 @@ using skipped lines as paragraph breaks, and tabs for indented quotations:
<span class="plain-syntax"> standard letters are allowed:</span>
<span class="plain-syntax"> The quick brown fox jumped over the lazy dog.</span>
<span class="plain-syntax"> Jinxed wizards pluck ivy from my quilt.</span>
<span class="plain-syntax"> Jinxed wizards pluck ivy from my big quilt.</span>
<span class="plain-syntax"> Jackdaws love my big sphinx of quartz.</span>
<span class="plain-syntax"> The second para begins here, after the</span>
@ -520,59 +520,50 @@ Inform repository, the example Alpaca Farm lives in:
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax"> Documentation/Examples/Alpaca.txt</span>
<span class="plain-syntax"> Documentation/Examples/AlpacaFarm.txt</span>
</pre>
<p class="commentary">Example files are just like volume files except that they open with a
special three-line header of metadata. In this example, it's:
special header of metadata. In this example, it's:
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax"> * New commands for old grammar</span>
<span class="plain-syntax"> (USE action which divines rational behavior for a wide range of possible nouns; Alpaca Farm)</span>
<span class="plain-syntax"> A generic USE action which behaves sensibly with a range of different objects.</span>
<span class="plain-syntax"> Example: * Alpaca Farm</span>
<span class="plain-syntax"> Location: New commands for old grammar</span>
<span class="plain-syntax"> RecipeLocation: Clarification and Correction</span>
<span class="plain-syntax"> Index: USE action which divines rational behavior for a wide range of possible nouns</span>
<span class="plain-syntax"> Description: A generic USE action which behaves sensibly with a range of different objects.</span>
<span class="plain-syntax"> For: Z-Machine</span>
</pre>
<p class="commentary">Line 1 opens with one to four asterisks, which is the star rating (a measure
of difficulty/complexity), and then gives the section name to which it belongs.
This should be a section name in the primary volume, if there are two. (For
Inform, that's "Writing with Inform".)
<p class="commentary">Line 1 is required to take the form <span class="extract"><span class="extract-syntax">Example: *** TITLE</span></span>, for some number of
asterisks between one and four - a measure of difficulty/complexity. By
convention the filename will be the same as the title but with punctuation
removed, but that is just a convention, and any filename can be used.
</p>
<p class="commentary">Line 2 shows how to index the example, both thematically and, after the semicolon,
alphabetically.
<p class="commentary">After line 1, further metadata lines can optionally appear, in any order, and then there
should be a skipped (i.e. completely blank) line before the body of the example
appears.
</p>
<p class="commentary">Line 3 is the "strapline" shown under the example title in the documentation.
</p>
<p class="commentary firstcommentary"><a id="SP18" class="paragraph-anchor"></a><b>&#167;18. </b>The above metadata is not quite enough to locate the example, because it
only gives a position in the primary volume (e.g., "Writing with Inform").
Where should the example go in the secondary (e.g., "The Inform Recipe Book")?
</p>
<p class="commentary">The answer is provided by the special file
<p class="commentary">The possible metadata lines are:
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">Location: SECTION</span></span> gives the section name which an example should go into,
in the primary volume, if there are two. (For Inform, that's "Writing with Inform".)
</li><li>(b) <span class="extract"><span class="extract-syntax">RecipeLocation: SECTION</span></span> similarly for the secondary volume. (For Inform,
that's "The Recipe Book".)
</li><li>(c) <span class="extract"><span class="extract-syntax">Index: ENTRY</span></span> gives the example this explanatory index entry in the alphabetical
index of examples.
</li><li>(d) <span class="extract"><span class="extract-syntax">Description: DESC</span></span> gives some text to use in the example heading, to explain
what it exemplifies.
</li><li>(e) <span class="extract"><span class="extract-syntax">For: PLATFORM</span></span> is to do with testing the example, and is ignored by <span class="extract"><span class="extract-syntax">indoc</span></span>.
</li><li>(f) <span class="extract"><span class="extract-syntax">Subtitle: SUBTITLE</span></span> is used only for examples occurring in numbered sequences,
where the same idea is elaborated in successive examples. For example:
</li></ul>
<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax"> Documentation/Examples/(Recipes).txt</span>
<span class="plain-syntax"> Example: * Port Royal 2</span>
<span class="plain-syntax"> Subtitle: With one-way connections added</span>
</pre>
<p class="commentary">which is not an example, but a list of examples under chapter and section
names in the Recipe Book. This is fairly self-explanatory, but note that
examples appear not under their named ("Alpaca Farm") but under their
thematic descriptions ("USE action which divines rational behavior for a
wide range of possible nouns") &mdash; the point of which being that the Recipe
Book is organised by theme.
</p>
<p class="commentary">There's one special notation, for use at the top of the recipes file:
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax"> Going Going == OMIT</span>
</pre>
<p class="commentary">This says that a named example, here "Going Going", should be omitted
altogether from the Recipe Book. (Inform omits about 12 of these.)
</p>
<nav role="progress"><div class="progresscontainer">
<ul class="progressbar"><li class="progressprev"><a href="M-vai.html">&#10094;</a></li><li class="progresscurrentchapter">M</li><li class="progresssection"><a href="M-iti.html">iti</a></li><li class="progresssection"><a href="M-vai.html">vai</a></li><li class="progresscurrent">dm</li><li class="progresssection"><a href="M-rc.html">rc</a></li><li class="progresschapter"><a href="1-bsc.html">1</a></li><li class="progresschapter"><a href="2-ss.html">2</a></li><li class="progresschapter"><a href="3-iu.html">3</a></li><li class="progresschapter"><a href="4-nd.html">4</a></li><li class="progressnext"><a href="M-rc.html">&#10095;</a></li></ul></div>
</nav><!--End of weave-->

View file

@ -18,11 +18,12 @@ typedef struct example {
struct filename *ex_filename;
struct text_stream *ex_outline;
struct text_stream *ex_public_name;
struct text_stream *ex_rubric;
struct text_stream *ex_rubric_pared_down;
struct text_stream *ex_index;
struct text_stream *ex_subtitle;
struct text_stream *ex_stars;
struct text_stream *ex_sort_key;
int ex_star_count;
int ex_header_length;
struct section *example_belongs_to_section[MAX_VOLUMES]; /* e.g., an example might belong to section 7 */
struct section *example_displayed_at_section[MAX_VOLUMES]; /* but be held back and appear at end of section 23 */
int example_position[MAX_VOLUMES]; /* sequence, counting from 0 */
@ -32,7 +33,7 @@ typedef struct example {
@ Examples are referenced both by a flat array (in ENO order) and in a hash
of their names:
@d MAX_EXAMPLES 1000
@d MAX_EXAMPLES 10000
=
example *examples[MAX_EXAMPLES];
@ -44,7 +45,6 @@ dictionary *examples_by_name = NULL;
dictionary *recipe_location = NULL;
dictionary *recipe_sort_prefix = NULL;
dictionary *recipe_subheading_of = NULL;
dictionary *recipe_translates_as = NULL;
@h Example scanning.
Each Example has its own file, which consists of a three-line header, and
@ -68,11 +68,14 @@ void Examples::scan_examples(void) {
text_stream *entry;
LOOP_OVER_LINKED_LIST(entry, text_stream, L) {
if (Platform::is_folder_separator(Str::get_last_char(entry))) continue;
if (Str::includes(entry, I"-I.")) continue;
filename *exloc = Filenames::in(indoc_settings->examples_directory, entry);
if (Regexp::match(NULL, entry, L"%(Recipes%)%c*")) @<Scan the Recipe Book catalogue@>
else @<Scan a regular example@>;
example *E = CREATE(example);
@<Initialise the example@>;
if (no_examples >= MAX_EXAMPLES) Errors::fatal("too many examples");
examples[no_examples++] = E;
@<Scan the example@>;
}
@<Use the Recipe Book catalogue to place examples in the RB@>;
volume *V;
LOOP_OVER(V, volume) {
@<Work out the sequence of examples within this volume@>;
@ -80,14 +83,28 @@ void Examples::scan_examples(void) {
}
}
@<Scan a regular example@> =
example *E = CREATE(example);
if (no_examples >= MAX_EXAMPLES)
Errors::fatal("too many examples");
examples[no_examples++] = E;
@<Initialise the example@> =
E->ex_filename = exloc;
E->ex_outline = NULL;
E->ex_public_name = NULL;
E->ex_index = NULL;
E->ex_subtitle = NULL;
E->ex_stars = NULL;
E->ex_sort_key = NULL;
E->ex_star_count = 1;
E->ex_header_length = 0;
E->example_belongs_to_section[0] = NULL;
E->example_belongs_to_section[1] = NULL;
E->example_displayed_at_section[0] = NULL;
E->example_displayed_at_section[1] = NULL;
E->example_position[0] = 0;
E->example_position[1] = 0;
@<Scan the example@> =
examples_helper_state ehs;
ehs.E = E;
ehs.ef = exloc;
ehs.body_reached = FALSE;
TextFiles::read(exloc, FALSE, "can't read example file",
TRUE, Examples::examples_helper, NULL, &ehs);
@ -95,163 +112,77 @@ void Examples::scan_examples(void) {
typedef struct examples_helper_state {
struct example *E;
struct filename *ef;
int body_reached;
} examples_helper_state;
void Examples::examples_helper(text_stream *line, text_file_position *tfp, void *v_ehs) {
examples_helper_state *ehs = (examples_helper_state *) v_ehs;
example *E = ehs->E;
Str::trim_white_space_at_end(line);
match_results mr = Regexp::create_mr();
if (tfp->line_count == 1) @<Scan line 1 of the example header@>;
if (tfp->line_count == 2) @<Scan line 2 of the example header@>;
if (tfp->line_count == 3) @<Scan line 3 of the example header@>;
Regexp::dispose_of(&mr);
}
@<Scan line 1 of the example header@> =
if (Regexp::match(&mr, line, L" *(%*+) (%c*)")) {
text_stream *asterisk_text = mr.exp[0];
text_stream *sname = mr.exp[1];
E->ex_stars = Str::duplicate(asterisk_text);
int starc = 0;
if (Str::eq_wide_string(E->ex_stars, L"*")) starc=1;
if (Str::eq_wide_string(E->ex_stars, L"**")) starc=2;
if (Str::eq_wide_string(E->ex_stars, L"***")) starc=3;
if (Str::eq_wide_string(E->ex_stars, L"****")) starc=4;
if (starc == 0) {
Errors::in_text_file("star count for example must be * to ****", tfp);
starc = 1;
}
E->ex_star_count = starc;
section *S = Dictionaries::read_value(volumes[0]->sections_by_name, sname);
if (S) E->example_belongs_to_section[0] = S;
else {
E->example_belongs_to_section[0] = NULL;
Errors::in_text_file("example belongs to an unknown section", tfp);
}
E->ex_filename = ehs->ef;
} else {
Errors::in_text_file("example has a malformed first line", tfp);
}
@<Scan line 2 of the example header@> =
if (Regexp::match(&mr, line, L" *%((%c*?)%)")) {
match_results mr2 = Regexp::create_mr();
E->ex_rubric = Str::duplicate(mr.exp[0]);
TEMPORARY_TEXT(rb)
Str::copy(rb, E->ex_rubric);
if (Regexp::match(&mr2, rb, L"(%c*?) *-- *(%c*)")) Str::copy(rb, mr2.exp[1]);
if (Regexp::match(&mr2, rb, L"(%c*); *(%c*?)")) Str::copy(rb, mr2.exp[0]);
if (Regexp::match(&mr2, rb, L"(%c*?): *(%c*?)")) Str::copy(rb, mr2.exp[1]);
E->ex_rubric_pared_down = Str::duplicate(rb);
DISCARD_TEXT(rb)
TEMPORARY_TEXT(name)
Str::copy(name, E->ex_rubric);
if (Regexp::match(&mr2, name, L"%c*;(%c*?)")) Str::copy(name, mr2.exp[0]);
if (Regexp::match(&mr2, name, L"(%c*?): (%d+). %c*")) {
Str::clear(name);
WRITE_TO(name, "%S %S", mr2.exp[0], mr2.exp[1]);
}
Str::trim_white_space(name);
E->ex_public_name = Str::duplicate(name);
if (examples_by_name == NULL) examples_by_name = Dictionaries::new(100, FALSE);
Dictionaries::create(examples_by_name, name);
Dictionaries::write_value(examples_by_name, name, E);
DISCARD_TEXT(name)
Regexp::dispose_of(&mr2);
} else {
Errors::in_text_file("example has a malformed second line", tfp);
}
@<Scan line 3 of the example header@> =
E->ex_outline = Str::duplicate(line);
@ The RB catalogue has a rather arcane format: see the file itself to be
(slightly) enlightened.
@<Scan the Recipe Book catalogue@> =
examples_rb_helper_state erbhs;
erbhs.current_rch = Str::new();
erbhs.current_rcsh = Str::new();
erbhs.no_recipe_headings = 0;
erbhs.no_recipe_subheadings = 0;
TextFiles::read(exloc, FALSE, "can't read Recipe Book catalogue file",
TRUE, Examples::examples_rb_helper, NULL, &erbhs);
@ =
typedef struct examples_rb_helper_state {
struct text_stream *current_rch;
struct text_stream *current_rcsh;
int no_recipe_headings;
int no_recipe_subheadings;
} examples_rb_helper_state;
void Examples::examples_rb_helper(text_stream *line, text_file_position *tfp, void *v_erbhs) {
examples_rb_helper_state *erbhs = (examples_rb_helper_state *) v_erbhs;
Str::trim_white_space(line);
if (ehs->body_reached) return;
if (Str::is_whitespace(line)) { ehs->body_reached = TRUE; return; }
E->ex_header_length++;
match_results mr = Regexp::create_mr();
if (Regexp::match(&mr, line, L" *(%c*?) *== *(%c*?)")) @<Scan a translation line@>
else if (Regexp::match(&mr, line, L">(%c*)")) @<Scan a major heading@>
else if (Regexp::match(&mr, line, L"%*(%c*)")) @<Scan a minor heading@>
else if (Str::len(line) > 0) @<Scan an example name@>;
Regexp::dispose_of(&mr);
}
@<Scan a translation line@> =
if (recipe_translates_as == NULL) recipe_translates_as = Dictionaries::new(100, TRUE);
text_stream *trans = Dictionaries::create_text(recipe_translates_as, mr.exp[0]);
Str::copy(trans, mr.exp[1]);
@<Scan a major heading@> =
Str::copy(erbhs->current_rch, mr.exp[0]);
erbhs->no_recipe_headings++;
Str::clear(erbhs->current_rcsh);
erbhs->no_recipe_subheadings = 0;
@<Scan a minor heading@> =
Str::copy(erbhs->current_rcsh, mr.exp[0]);
erbhs->no_recipe_subheadings++;
@<Scan an example name@> =
if (recipe_subheading_of == NULL) recipe_subheading_of = Dictionaries::new(100, TRUE);
text_stream *rso = Dictionaries::create_text(recipe_subheading_of, line);
Str::copy(rso, erbhs->current_rcsh);
if (recipe_location == NULL) recipe_location = Dictionaries::new(100, TRUE);
text_stream *rl = Dictionaries::create_text(recipe_location, line);
Str::copy(rl, erbhs->current_rcsh);
if (Str::eq_wide_string(line, L"About the examples")) Str::copy(rl, I"PREFACE");
if (Str::eq_wide_string(line, L"Basic room, container, and supporter descriptions"))
Str::copy(rl, I"PREFACE");
if (recipe_sort_prefix == NULL) recipe_sort_prefix = Dictionaries::new(100, TRUE);
text_stream *rsp = Dictionaries::create_text(recipe_sort_prefix, line);
WRITE_TO(rsp, "%02d_%02d", erbhs->no_recipe_headings, erbhs->no_recipe_subheadings);
@<Use the Recipe Book catalogue to place examples in the RB@> =
volume *V;
LOOP_OVER(V, volume) {
if (V->allocation_id == 0) continue; /* placings in WWI are already made */
example *E;
LOOP_OVER(E, example) {
text_stream *to_find = E->ex_rubric_pared_down;
text_stream *sname = Dictionaries::get_text(recipe_location, to_find);
if (sname == NULL) Errors::with_text("recipe book lookup failed (1): %S", to_find);
else {
section *S = (section *) Dictionaries::read_value(V->sections_by_name, sname);
if (S == NULL) Errors::with_text(
"recipe book lookup failed: %S refers to nonexistent section", to_find);
if (tfp->line_count == 1) {
if (Regexp::match(&mr, line, L"Example *: *(%*+) (%c*)")) {
text_stream *asterisk_text = mr.exp[0];
text_stream *name = mr.exp[1];
E->ex_stars = Str::duplicate(asterisk_text);
int starc = 0;
if (Str::eq_wide_string(E->ex_stars, L"*")) starc=1;
if (Str::eq_wide_string(E->ex_stars, L"**")) starc=2;
if (Str::eq_wide_string(E->ex_stars, L"***")) starc=3;
if (Str::eq_wide_string(E->ex_stars, L"****")) starc=4;
if (starc == 0) {
Errors::in_text_file("star count for example must be * to ****", tfp);
starc = 1;
}
E->ex_star_count = starc;
E->ex_public_name = Str::duplicate(name);
if (examples_by_name == NULL) examples_by_name = Dictionaries::new(100, FALSE);
Dictionaries::create(examples_by_name, name);
Dictionaries::write_value(examples_by_name, name, E);
} else {
Errors::in_text_file("first line should read 'Example: ** Title'", tfp);
}
} else {
if (Regexp::match(&mr, line, L"(%C+?) *: *(%c*)")) {
text_stream *field = mr.exp[0];
text_stream *content = mr.exp[1];
if (Str::eq(field, I"Example")) {
Errors::in_text_file("'Example:' should be on line 1", tfp);
} else if (Str::eq(field, I"Location")) {
text_stream *sname = content;
section *S = Dictionaries::read_value(volumes[0]->sections_by_name, sname);
if (S) E->example_belongs_to_section[0] = S;
else {
E->example_belongs_to_section[V->allocation_id] = S;
E->example_belongs_to_section[0] = NULL;
Errors::in_text_file("example belongs to an unknown section", tfp);
}
E->ex_filename = ehs->ef;
} else if (Str::eq(field, I"Description")) {
E->ex_outline = Str::duplicate(content);
} else if (Str::eq(field, I"For")) {
; /* not relevant to indoc */
} else if (Str::eq(field, I"Index")) {
E->ex_index = Str::duplicate(content);
} else if (Str::eq(field, I"Subtitle")) {
E->ex_subtitle = Str::duplicate(content);
} else if (Str::eq(field, I"RecipeLocation")) {
text_stream *sname = content;
section *S = Dictionaries::read_value(volumes[1]->sections_by_name, sname);
if (S) E->example_belongs_to_section[1] = S;
else {
E->example_belongs_to_section[1] = NULL;
Errors::in_text_file("example belongs to an unknown section", tfp);
}
} else {
Errors::in_text_file("no such example details field", tfp);
}
}
}
Regexp::dispose_of(&mr);
}
@ At this point, then, we know which section every example belongs to. But
we still have to put them in order within those sections: we want 1-star
@ -401,13 +332,7 @@ other book.
@<Render the example name@> =
HTML_OPEN("b");
TEMPORARY_TEXT(text_of_name)
Str::copy(text_of_name, E->ex_rubric);
match_results mr = Regexp::create_mr();
if (Regexp::match(&mr, text_of_name, L"%c*;(%c*?)")) Str::copy(text_of_name, mr.exp[0]);
if (Regexp::match(&mr, text_of_name, L"(%c*?): (%d+)%c*")) {
Str::clear(text_of_name);
WRITE_TO(text_of_name, "%S %S", mr.exp[0], mr.exp[1]);
}
Str::copy(text_of_name, E->ex_public_name);
Str::trim_white_space(text_of_name);
Rawtext::escape_HTML_characters_in(text_of_name);
if (indoc_settings->navigation->simplified_examples == FALSE) {
@ -421,7 +346,6 @@ other book.
WRITE("Example %d: %S", E->example_position[0], text_of_name);
}
DISCARD_TEXT(text_of_name)
Regexp::dispose_of(&mr);
HTML_CLOSE("b");
@<Render the example cue right surround@> =

View file

@ -57,7 +57,7 @@ text_stream *Rawtext::turn_rawtext_into_blocks(OUTPUT_STREAM,
rhs->no_blocks_read_in_current_chapter = 0;
rhs->no_pars_read_in_current_block = 0;
rhs->title_of_block_being_read = Str::new(); /* Untitled until a block heading found */
if (E) rhs->skip_opening_lines = 3;
if (E) rhs->skip_opening_lines = E->ex_header_length;
else rhs->skip_opening_lines = 0;
@<Prepare to read a new chapter of rawtext@>;

View file

@ -272,7 +272,7 @@ very much.
if ((index_to_examples) &&
(Regexp::match(&mr, raw, L"{%*}&quot;(%c*)&quot;%c*")) &&
(Str::ne_wide_string(mr.exp[0], L"Midsummer Day"))) {
ExamplesIndex::add_to_alphabetic_examples_index(mr.exp[0], S, NULL, TRUE, FALSE);
ExamplesIndex::add_to_alphabetic_examples_index(mr.exp[0], S, NULL, TRUE);
Regexp::dispose_of(&mr);
}

View file

@ -27,57 +27,17 @@ that, some example snippets embedded in the body text of the manuals can
also appear here. So we actually maintain an alphabetical index able to
index examples under arbitrary, multiple descriptions.
If this is called with the |RB_flag| set, then it adds the entry to the
thematic index instead, which shares code here because it also involves a
degree of alphabetisation.
=
void ExamplesIndex::add_to_alphabetic_examples_index(text_stream *given_rubric,
section *index_to_S, example *index_to_E, int bold_flag, int RB_flag) {
TEMPORARY_TEXT(rubric)
Str::copy(rubric, given_rubric);
match_results mr = Regexp::create_mr();
if (Regexp::match(&mr, rubric, L"(%c*); *(%c*?)")) {
ExamplesIndex::add_to_alphabetic_examples_index(mr.exp[0], index_to_S, index_to_E, bold_flag, RB_flag);
ExamplesIndex::add_to_alphabetic_examples_index(mr.exp[1], index_to_S, index_to_E, TRUE, RB_flag);
} else {
if (RB_flag) @<Translate the rubric according to the Recipe Book catalogue@>;
@<Add a single new term to the examples index@>;
}
Regexp::dispose_of(&mr);
DISCARD_TEXT(rubric)
}
@<Translate the rubric according to the Recipe Book catalogue@> =
text_stream *trans = Dictionaries::get_text(recipe_translates_as, rubric);
if (Str::len(trans) > 0) {
if (Str::eq(trans, I"OMIT")) return;
Str::copy(rubric, trans);
}
@<Add a single new term to the examples index@> =
section *index_to_S, example *index_to_E, int bold_flag) {
TEMPORARY_TEXT(sort_key)
TEMPORARY_TEXT(subtitle)
Str::copy(sort_key, rubric);
if (Regexp::match(&mr, rubric, L"(%c*?) *-- *(%c*)")) Str::copy(rubric, mr.exp[0]);
if (Regexp::match(&mr, rubric, L"(%c*?): *(%c*?)")) {
Str::copy(rubric, mr.exp[1]);
Str::copy(subtitle, mr.exp[0]);
}
Str::copy(sort_key, given_rubric);
IndexUtilities::improve_alphabetisation(sort_key);
if (RB_flag) {
text_stream *pre = Dictionaries::get_text(recipe_sort_prefix, rubric);
if (Str::len(pre) > 0) {
TEMPORARY_TEXT(p)
WRITE_TO(p, "%S>%S", pre, sort_key);
Str::copy(sort_key, p);
DISCARD_TEXT(p)
}
}
example_index_data *eid = CREATE(example_index_data);
eid->alpha_index_embolden = bold_flag;
eid->alpha_index_rubric = Str::duplicate(rubric);
eid->alpha_index_rubric = Str::duplicate(given_rubric);
eid->alpha_index_subtitle = Str::duplicate(subtitle);
eid->alpha_index_to_S = index_to_S;
eid->alpha_index_to_E = index_to_E;
@ -87,6 +47,7 @@ void ExamplesIndex::add_to_alphabetic_examples_index(text_stream *given_rubric,
example_index_data_by_rubric = Dictionaries::new(100, FALSE);
Dictionaries::create(example_index_data_by_rubric, sort_key);
Dictionaries::write_value(example_index_data_by_rubric, sort_key, (void *) eid);
}
@h Alphabetic index of examples.
@ -131,8 +92,20 @@ void ExamplesIndex::write_alphabetical_examples_index(void) {
@<Stock the alphabetical index@> =
example *E;
LOOP_OVER(E, example)
ExamplesIndex::add_to_alphabetic_examples_index(E->ex_rubric, NULL, E, FALSE, FALSE);
LOOP_OVER(E, example) {
if (Str::len(E->ex_subtitle) > 0) {
TEMPORARY_TEXT(index_as)
WRITE_TO(index_as, "%S: %S", E->ex_public_name, E->ex_subtitle);
ExamplesIndex::add_to_alphabetic_examples_index(index_as, NULL, E, TRUE);
DISCARD_TEXT(index_as)
} else if (Str::eq(E->ex_index, E->ex_public_name)) {
ExamplesIndex::add_to_alphabetic_examples_index(E->ex_index, NULL, E, FALSE);
} else {
ExamplesIndex::add_to_alphabetic_examples_index(E->ex_public_name, NULL, E, TRUE);
if (Str::len(E->ex_index) > 0)
ExamplesIndex::add_to_alphabetic_examples_index(E->ex_index, NULL, E, FALSE);
}
}
@<Work out the URL of this example@> =
if (eid->alpha_index_to_S)

View file

@ -12,7 +12,7 @@ using skipped lines as paragraph breaks, and tabs for indented quotations:
standard letters are allowed:
The quick brown fox jumped over the lazy dog.
Jinxed wizards pluck ivy from my quilt.
Jinxed wizards pluck ivy from my big quilt.
Jackdaws love my big sphinx of quartz.
The second para begins here, after the
@ -359,44 +359,48 @@ at the appropriate places under C and A.
Recall that each Example provided with the documentation -- usually a
sample program -- has its own source file. For example, in the standard
Inform repository, the example Alpaca Farm lives in:
= (text as Indoc)
Documentation/Examples/Alpaca.txt
= (text)
Documentation/Examples/AlpacaFarm.txt
=
Example files are just like volume files except that they open with a
special three-line header of metadata. In this example, it's:
= (text as Indoc)
* New commands for old grammar
(USE action which divines rational behavior for a wide range of possible nouns; Alpaca Farm)
A generic USE action which behaves sensibly with a range of different objects.
special header of metadata. In this example, it's:
= (text)
Example: * Alpaca Farm
Location: New commands for old grammar
RecipeLocation: Clarification and Correction
Index: USE action which divines rational behavior for a wide range of possible nouns
Description: A generic USE action which behaves sensibly with a range of different objects.
For: Z-Machine
=
Line 1 opens with one to four asterisks, which is the star rating (a measure
of difficulty/complexity), and then gives the section name to which it belongs.
This should be a section name in the primary volume, if there are two. (For
Inform, that's "Writing with Inform".)
Line 1 is required to take the form |Example: *** TITLE|, for some number of
asterisks between one and four - a measure of difficulty/complexity. By
convention the filename will be the same as the title but with punctuation
removed, but that is just a convention, and any filename can be used.
Line 2 shows how to index the example, both thematically and, after the semicolon,
alphabetically.
After line 1, further metadata lines can optionally appear, in any order, and then there
should be a skipped (i.e. completely blank) line before the body of the example
appears.
Line 3 is the "strapline" shown under the example title in the documentation.
The possible metadata lines are:
@ The above metadata is not quite enough to locate the example, because it
only gives a position in the primary volume (e.g., "Writing with Inform").
Where should the example go in the secondary (e.g., "The Inform Recipe Book")?
(a) |Location: SECTION| gives the section name which an example should go into,
in the primary volume, if there are two. (For Inform, that's "Writing with Inform".)
The answer is provided by the special file
= (text as Indoc)
Documentation/Examples/(Recipes).txt
(b) |RecipeLocation: SECTION| similarly for the secondary volume. (For Inform,
that's "The Recipe Book".)
(c) |Index: ENTRY| gives the example this explanatory index entry in the alphabetical
index of examples.
(d) |Description: DESC| gives some text to use in the example heading, to explain
what it exemplifies.
(e) |For: PLATFORM| is to do with testing the example, and is ignored by |indoc|.
(f) |Subtitle: SUBTITLE| is used only for examples occurring in numbered sequences,
where the same idea is elaborated in successive examples. For example:
= (text)
Example: * Port Royal 2
Subtitle: With one-way connections added
=
which is not an example, but a list of examples under chapter and section
names in the Recipe Book. This is fairly self-explanatory, but note that
examples appear not under their named ("Alpaca Farm") but under their
thematic descriptions ("USE action which divines rational behavior for a
wide range of possible nouns") -- the point of which being that the Recipe
Book is organised by theme.
There's one special notation, for use at the top of the recipes file:
= (text as Indoc)
Going Going == OMIT
=
This says that a named example, here "Going Going", should be omitted
altogether from the Recipe Book. (Inform omits about 12 of these.)

View file

@ -1,33 +1,33 @@
Total memory consumption was 137284K = 134 MB
Total memory consumption was 139642K = 136 MB
---- was used for 2123161 objects, in 374915 frames in 0 x 800K = 0K = 0 MB:
30.7% inter_tree_node_array 60 x 8192 = 491520 objects, 43255680 bytes
19.5% text_stream_array 4883 x 100 = 488300 objects, 27501056 bytes
18.0% linked_list 45352 objects, 25397120 bytes
10.2% inter_symbol_array 135 x 1024 = 138240 objects, 14381280 bytes
9.9% inter_error_stash_array 107 x 1024 = 109568 objects, 14028128 bytes
7.6% parse_node 133796 objects, 10703680 bytes
5.4% verb_conjugation 164 objects, 7610912 bytes
30.2% inter_tree_node_array 60 x 8192 = 491520 objects, 43255680 bytes
19.2% text_stream_array 4883 x 100 = 488300 objects, 27501056 bytes
17.7% linked_list 45352 objects, 25397120 bytes
10.0% inter_symbol_array 135 x 1024 = 138240 objects, 14381280 bytes
9.8% inter_error_stash_array 107 x 1024 = 109568 objects, 14028128 bytes
7.4% parse_node 133796 objects, 10703680 bytes
5.3% verb_conjugation 164 objects, 7610912 bytes
4.0% parse_node_annotation_array 357 x 500 = 178500 objects, 5723424 bytes
3.2% scan_directory 1092 objects, 4507776 bytes
2.5% pcalc_prop_array 26 x 1000 = 26000 objects, 3536832 bytes
3.1% scan_directory 1092 objects, 4507776 bytes
2.4% pcalc_prop_array 26 x 1000 = 26000 objects, 3536832 bytes
2.2% inter_name_array 67 x 1000 = 67000 objects, 3218144 bytes
1.9% kind_array 68 x 1000 = 68000 objects, 2722176 bytes
1.5% inter_schema_token 14176 objects, 2154752 bytes
1.4% inter_name_generator_array 51 x 1000 = 51000 objects, 2041632 bytes
1.3% package_request 21344 objects, 1878272 bytes
1.3% vocabulary_entry_array 163 x 100 = 16300 objects, 1830816 bytes
1.2% vocabulary_entry_array 163 x 100 = 16300 objects, 1830816 bytes
1.1% dict_entry_array 491 x 100 = 49100 objects, 1586912 bytes
1.0% inter_symbols_table 26921 objects, 1507576 bytes
1.0% match_trie_array 11 x 1000 = 11000 objects, 1496352 bytes
1.0% i6_schema_array 24 x 100 = 2400 objects, 1440768 bytes
0.9% inter_package 26921 objects, 1292208 bytes
0.8% map_data 677 objects, 1137360 bytes
0.7% map_data 677 objects, 1137360 bytes
0.7% id_body 979 objects, 1119976 bytes
0.7% adjective_meaning 208 objects, 1030016 bytes
0.7% inter_schema_node 9066 objects, 1015392 bytes
0.7% excerpt_meaning 3164 objects, 987168 bytes
0.6% excerpt_meaning 3164 objects, 987168 bytes
0.6% production 3985 objects, 924520 bytes
0.6% ptoken 8652 objects, 899808 bytes
0.6% grammatical_usage 3648 objects, 875520 bytes
@ -47,7 +47,7 @@ Total memory consumption was 137284K = 134 MB
0.1% hierarchy_location 1190 objects, 171360 bytes
0.1% linguistic_stock_item 3338 objects, 160224 bytes
0.1% rule_family_data 404 objects, 148672 bytes
0.1% nonterminal 773 objects, 142232 bytes
---- nonterminal 773 objects, 142232 bytes
---- nascent_array 2130 objects, 136320 bytes
---- inference 1705 objects, 122760 bytes
---- pcalc_term_array 3 x 1000 = 3000 objects, 120096 bytes
@ -263,23 +263,23 @@ Total memory consumption was 137284K = 134 MB
100.0% was used for memory not allocated for objects:
61.6% text stream storage 86714112 bytes in 508313 claims
62.3% text stream storage 89129024 bytes in 508657 claims
3.8% dictionary storage 5480960 bytes in 7754 claims
---- sorting 2624 bytes in 531 claims
5.1% source text 7200000 bytes in 3 claims
7.6% source text details 10800000 bytes in 2 claims
5.0% source text 7200000 bytes in 3 claims
7.5% source text details 10800000 bytes in 2 claims
0.1% documentation fragments 262144 bytes in 1 claim
---- linguistic stock array 81920 bytes in 2 claims
---- small word set array 105600 bytes in 22 claims
3.3% inter symbols storage 4704736 bytes in 28298 claims
11.9% inter bytecode storage 16758228 bytes in 15 claims
4.4% inter links storage 6222976 bytes in 11 claims
3.2% inter symbols storage 4704736 bytes in 28298 claims
11.7% inter bytecode storage 16758228 bytes in 15 claims
4.3% inter links storage 6222976 bytes in 11 claims
0.1% inter tree location list storage 191232 bytes in 32 claims
1.2% instance-of-kind counting 1731856 bytes in 1 claim
---- compilation workspace for objects 21936 bytes in 25 claims
---- lists for type-checking invocations 16000 bytes in 1 claim
---- code generation workspace for objects 3488 bytes in 19 claims
0.2% emitter array storage 281184 bytes in 2006 claims
0.1% emitter array storage 281184 bytes in 2006 claims
-138.-7% was overhead - -195021008 bytes = -190450K = -185 MB
-136.-3% was overhead - -195021008 bytes = -190450K = -185 MB

View file

@ -1,30 +1,29 @@
100.0% in inform7 run
67.1% in compilation to Inter
45.5% in //Sequence::undertake_queued_tasks//
67.8% in compilation to Inter
45.8% in //Sequence::undertake_queued_tasks//
4.1% in //MajorNodes::pre_pass//
3.3% in //MajorNodes::pass_1//
3.7% in //MajorNodes::pass_1//
1.8% in //ImperativeDefinitions::assess_all//
1.4% in //RTKindConstructors::compile//
1.4% in //RTPhrasebook::compile_entries//
1.8% in //RTPhrasebook::compile_entries//
1.5% in //RTKindConstructors::compile//
1.1% in //Sequence::lint_inter//
0.7% in //ImperativeDefinitions::compile_first_block//
0.7% in //Sequence::undertake_queued_tasks//
0.3% in //CompletionModule::compile//
0.3% in //ImperativeDefinitions::compile_first_block//
0.3% in //MajorNodes::pass_2//
0.3% in //RTKindConstructors::compile_permissions//
0.3% in //Sequence::undertake_queued_tasks//
0.3% in //World::stage_V//
4.8% not specifically accounted for
28.7% in running Inter pipeline
9.7% in step 14/15: generate inform6 -> auto.inf
7.0% in step 5/15: load-binary-kits
5.9% in step 6/15: make-synoptic-module
4.6% not specifically accounted for
27.6% in running Inter pipeline
9.4% in step 14/15: generate inform6 -> auto.inf
6.8% in step 5/15: load-binary-kits
5.6% in step 6/15: make-synoptic-module
1.8% in step 9/15: make-identifiers-unique
0.3% in step 11/15: eliminate-redundant-labels
0.3% in step 12/15: eliminate-redundant-operations
0.3% in step 4/15: compile-splats
0.3% in step 7/15: shorten-wiring
0.3% in step 8/15: detect-indirect-calls
2.3% not specifically accounted for
3.3% in supervisor
0.8% not specifically accounted for
3.4% in supervisor
1.2% not specifically accounted for

View file

@ -2,7 +2,7 @@
"is": {
"type": "kit",
"title": "Architecture16Kit",
"version": "10.2.0-beta+6W89"
"version": "10.2.0-beta+6W90"
},
"compatibility": "16-bit",
"kit-details": {

View file

@ -2,7 +2,7 @@
"is": {
"type": "kit",
"title": "Architecture32Kit",
"version": "10.2.0-beta+6W89"
"version": "10.2.0-beta+6W90"
},
"compatibility": "32-bit",
"kit-details": {

View file

@ -2,7 +2,7 @@
"is": {
"type": "kit",
"title": "BasicInformKit",
"version": "10.2.0-beta+6W89"
"version": "10.2.0-beta+6W90"
},
"needs": [ {
"need": {

View file

@ -2,7 +2,7 @@
"is": {
"type": "kit",
"title": "CommandParserKit",
"version": "10.2.0-beta+6W89"
"version": "10.2.0-beta+6W90"
},
"needs": [ {
"need": {

View file

@ -2,7 +2,7 @@
"is": {
"type": "kit",
"title": "EnglishLanguageKit",
"version": "10.2.0-beta+6W89"
"version": "10.2.0-beta+6W90"
},
"needs": [ {
"need": {

View file

@ -2,7 +2,7 @@
"is": {
"type": "kit",
"title": "WorldModelKit",
"version": "10.2.0-beta+6W89"
"version": "10.2.0-beta+6W90"
},
"needs": [ {
"need": {

View file

@ -24,7 +24,7 @@
-cases [Internal] 'inform7/Tests/Test Internals'
-cases [Make] 'inform7/Tests/Test Makes'
-cases [Filing] 'inform7/Tests/Test Filings'
-examples [Main] resources/Documentation/Examples
-examples [Exemplary] resources/Documentation/Examples
-problems [Main] 'inform7/Tests/Test Problems'
-singular temp
@ -197,6 +197,169 @@
-end
-recipe [Exemplary]
set: $I6 = inform6/Tangled/inform6
set: $I7 = inform7/Tangled/inform7
set: $INTERNAL = inform7/Internal
set: $WORKSPACE = intest/Workspace
set: $ZINT = inform6/Tests/Assistants/dumb-frotz/dumb-frotz
set: $GINT = inform6/Tests/Assistants/dumb-glulx/glulxe/glulxe
set: $TOC = NO
! First we decide whether to compile it for the Z-machine or Glulx.
set: $VM = Z
if: $CASE %c*-G
set: $VM = G
endif
if: $CASE %c*-C
set: $VM = G
set: $TOC = YES
endif
if: $CASE %c*Metric%c*Units%c*
set: $VM = G
endif
! On the basis of which:
if: $VM G
set: $FORMAT = Inform6/32
set: $EXT = ulx
set: $I6OPTIONS = -E2SDwGx
set: $INT = $GINT
set: $INTNAME = dumb-glulxe
set: $INTOPTIONS = -u -q
else
set: $FORMAT = Inform6/16
set: $EXT = z8
set: $I6OPTIONS = -E2SDwv8x
set: $INT = $ZINT
set: $INTNAME = dumb-frotz
set: $INTOPTIONS = -w 1000
endif
! Now we extract the source text from whatever file originated the test
! case: this is a non-trivial operation when the file is an Extension or
! an example, but is a simple copy operation otherwise.
extract: $WORK/Example.inform/Source/story.ni $VM
! Test cases from map indexing problem messages require ni to get as far as
! indexing, so the -no-index option mustn't be used in this case.
mkdir: $WORK/Transient
step: find $WORK/Transient -mindepth 1 -delete
mkdir: $PATH/_Results_Actual
if: $CASE PM_Map%c*
set: $I7OPTIONS = -format=$FORMAT -no-progress -no-resource-checking -fixtime -rng -sigils -log nothing -external inform7/Tests -transient $WORK/Transient -no-census-update -internal $INTERNAL
else
set: $I7OPTIONS = -format=$FORMAT -no-progress -no-resource-checking -fixtime -rng -sigils -log nothing -external inform7/Tests -transient $WORK/Transient -no-index -internal $INTERNAL
endif
set: $PIPELINE =
! First, problem message cases, where we require ni to fail and with the
! correct output.
if: $TYPE problem
set: $A = $PATH/_Results_Actual/$CASE.txt
set: $I = $PATH/$CASE-I.txt
debugger: lldb -f $I7 -- `$I7OPTIONS -require-problem $CASE -project $WORK/Example.inform $PIPELINE -crash-all
fail step: $I7 `$I7OPTIONS -require-problem $CASE -project $WORK/Example.inform $PIPELINE >$A 2>&1
or: 'failed to produce its namesake Problem message' $A
show: $A
exists: $I
or: 'produced Problem(s), but no ideal transcript existed'
match problem: $A $I
or: 'produced the wrong Problem message(s)'
pass: 'passed'
endif
step: rm -f notebook.glkdata prefs.glkdata barbara.glkdata
! And then the general case.
set: $I7CONSOLE = $WORK/Example.inform/Build/i7_output.txt
if: $TOC YES
mkdir: $PATH/_Textual
mkdir: $PATH/_C
set: $I7CLIB = inform7/Internal/Miscellany
set: $TOUT = $PATH/_Textual/$CASE.intert
set: $COUT = $PATH/_C/$CASE.c
set: $OFILE = $WORK/Example.inform/Build/$CASE.o
step: $I7 -fixtime -rng -sigils -format=C $WORK/Example.inform/Source/story.ni -variable *tout=$TOUT -o $COUT `$PIPELINE >$I7CONSOLE 2>&1
or: 'failed with Problem message(s)' $I7CONSOLE
set: $CCCONSOLE = $WORK/Example.inform/Build/cc_output.txt
set: $LINKCONSOLE = $WORK/Example.inform/Build/link_output.txt
set: $STORYFILE = $WORK/Example.inform/Build/final$$EXESUFFIX
step: `$$CCOMPILER -o $OFILE $COUT -I $I7CLIB >$CCCONSOLE 2>&1
or: 'failed to compile C' $CCCONSOLE
step: `$$CLINKER -o $STORYFILE $OFILE `$$LINKFLAGS >$LINKCONSOLE 2>&1
or: 'failed to link C' $LINKCONSOLE
set: $A = $PATH/_Results_Actual/$CASE.txt
set: $I = $PATH/$CASE-I.txt
step: $STORYFILE <$SCRIPT >$A 2>&1
or: 'failed to run C program' $A
show: $A
match text: $A $I
or: 'C program misbehaved'
step: rm -f notebook.glkdata prefs.glkdata barbara.glkdata
pass: 'passed'
else
debugger: lldb -f $I7 -- `$I7OPTIONS -format=$FORMAT -project $WORK/Example.inform $PIPELINE -crash-all
step: $I7 `$I7OPTIONS -format=$FORMAT -project $WORK/Example.inform $PIPELINE >$I7CONSOLE 2>&1
or: 'failed with Problem message(s)' $I7CONSOLE
show: $I7CONSOLE
set: $I6SOURCE = $WORK/Example.inform/Build/auto.inf
hash: $I6SOURCE $WORK/Example.inform/Build/checksum.txt
or: 'passed (matching cached I6 known to work)'
set: $I6CONSOLE = $WORK/Example.inform/Build/i6_output.txt
set: $STORYFILE = $WORK/Example.inform/Build/output.$EXT
step: $I6 `$I6OPTIONS $I6SOURCE $STORYFILE >$I6CONSOLE 2>&1
or: 'failed to pass through Inform 6' $I6CONSOLE
show i6: $I6CONSOLE
set: $A = $PATH/_Results_Actual/$CASE.txt
set: $I = $PATH/$CASE-I.txt
step: $INT `$INTOPTIONS $STORYFILE <$SCRIPT >$A 2>&1
or: 'unable to run $INTNAME (do you need to make interpreters?)'
exists: $I
or: 'translated successfully but no ideal transcript existed'
if: $VM G
match glulxe transcript: $A $I
or: 'played incorrectly'
else
match frotz transcript: $A $I
or: 'played incorrectly'
endif
step: rm -f notebook.glkdata prefs.glkdata barbara.glkdata
pass: 'passed'
endif
-end
-recipe [Basic]
set: $I6 = inform6/Tangled/inform6

View file

@ -1,707 +0,0 @@
Going Going == OMIT
Streaming == OMIT
Sackcloth == OMIT
Polygons == OMIT
Winds of Change == OMIT
America Stands Tall == OMIT
Studious == OMIT
Buttons == OMIT
Waiting Room == OMIT
Tour des Maillots == OMIT
Terracotta == OMIT
Appraisal == OMIT
>INTRODUCTION
*PREFACE
About the examples
Basic room, container, and supporter descriptions
*DISENCHANTMENT BAY
1. The charter boat
Basic scenery
Basic backdrop
Basic descriptions
Basic door
Basic locked container
Radar aboard ship
Basic pushable object
Basic character
Basic clothing
Basic holdall
12. Complete playable scenario
*INFORMATION ONLY
Formal syntax of sentences
Mathematical view of relations
Graph-theory view of relations
About Inform's regular expression support
>ADAPTIVE PROSE
*VARYING WHAT IS WRITTEN
Random variations within text
Phrase to let us say things some number of times
Substituting insults and boasts
To say rules for insults and boasts
Cyclical randomization of named objects
Names of objects change with player's diction
Say rules for is-are and it/them
Saying a number in round numbers
Otherwise if demonstrated
Exact numbers replaced with vague quantifiers
Creating our own text variations rules
Filtering text output in room names
Paragraphs of flexible descriptions
Case change for text produced by to say phrases
An example bouquet of flowers
Describing ongoing character behavior with participles
Describing relations using a random choice of verb
Describing action outcomes using a random choice of verb or describing the world state that results
Identifying nouns by the last thing done to them
Describing action outcomes using a random choice of verb
Inventory standard response changed
Describing action outcomes using an adaptive random choice of verb
Altering response text programmatically
*VARYING WHAT IS READ
Printed names for complex-named objects
Kinds given new singular and plural synonyms
Understanding names of things, basic
Questions asked of the player
Handling the nine-character limit
Setting pronouns to respond to sudden changes
*USING THE PLAYER'S INPUT
Understanding text
Fish of ambiguous species
Player's erroneous command recorded for later
Pig Latin for the player's commands
>PLACE
*ROOM DESCRIPTIONS
Varying room description text
Testing the locale description order
Levels of lighting
Supporters that don't list contents in room descriptions
Incorporating changeable objects into the body of the room description
LOOK mentions only currently useful objects
Room description changes after first visit
Room description changes at each of several visits
Room description changes after note is read
*MAP
1. A landscape from Jamaica, 1691
2. With one-way connections added
3. Divided into regions
Region off-limits to a player without VIP pass
Maze with randomized room links
Carousel Room from which exits lead to random locations
Exits added to a room
Map rearranged as player wanders so they find rooms in order
Compass directions renamed
A hexagonal map grid for movement
*DOORS, STAIRCASES, AND BRIDGES
Door described differently depending on where it is
Door kind that describes the destination
Door described and parsed differently depending on where it is
Doors that open automatically
An automatically closing door
Deadbolted door unlockable without a key on one side
Readout showing status of all doors
Doors as seen by NPCs
Staircase kind of door, always open and unopenable
Staircase kind of door which diverts the CLIMB command
Plank bridge breaks on being crossed when the player is carrying something
*POSITION WITHIN ROOMS
Rooms with visible exteriors
Pushing a box between named internal positions in a room
*CONTINUOUS SPACES AND THE OUTDOORS
Large objects visible from distant rooms
Lighthouse whose light can shine in different directions
Backdrops which can only be examined
LOOK [direction] command
Continuous space, simple
Continuous space with distant objects visible
Continuous space with distant objects visible and automatic room description
Signposts to distant rooms
*WINDOWS
Basic window similar to a door
Window that can be opaque or transparent
Random characters seen through a window
Window connecting two rooms
Windows in high places
*LIGHTING
Rooms with light effects
Light levels variable depending on the number of candles the player has lit
Torch understood as flaming or extinguished
Basic switchable light for a room
Electric light kind of device
Shiny items are described as reflecting torchlight
Dark rooms given non-standard description
Dark room which relies on other senses when light is off
Scope approaches compared
Light-filled rooms as a route through a space
Cloak that makes a room dark
*SOUNDS
Rooms with sounds of nearby water
Noisemaking gadgets which can be heard with LISTEN
Scope for listening different from scope for seeing
*PASSERS-BY, WEATHER AND ASTRONOMICAL EVENTS
Clouds with random descriptions
Randomized pedestrian passer-by
Atmospheric background events that occur randomly during a scene
Backdrops that move conditionally
Cycle of day and night scenes
Scheduling an eclipse
>TIME AND PLOT
*THE PASSAGE OF TIME
Time told in 24-hour military style
Time expressed in units other than minutes
Turns take 15 minutes each
Turns take a quarter day each
Instant EXAMINE and LOOK
All actions given different durations
Implicit takes require time
*SCRIPTED SCENES
Sequence of background events that plays out in order
Triggering a new scene when the player does any of several things
Hurrying the player on a specific task
Scenes which restrict movement
*EVENT SCHEDULING
Shops open and close at specific hours
People who follow a schedule of activities
Appointments at future times
*SCENE CHANGES
Moving props on and off-stage as scenes start and end
Moving a backdrop during play
Scenes with props lists and location properties
Commercial break
*FLASHBACKS
Flashback scenes, simple
Flashbacks with multiple outcomes
*PLOT MANAGEMENT
Goal-seeking plot manager, simple
>THE VIEWPOINT CHARACTER
*THE HUMAN BODY
Disambiguating body parts
Height of player affects descriptions
Postures for sitting, standing, and lying down
*TRAITS DETERMINED BY THE PLAYER
Name of player character selected at start of play
Asking the player to choose to be good or evil
Allowing the player to describe the main character before starting play
*CHARACTERIZATION
Another, distinct from the player
Restrictions preventing inappropriate behavior
Examining the player
*BACKGROUND
REMEMBER command keyed to topics
FIND command
*MEMORY AND KNOWLEDGE
Characters referred to when absent
Box reports whether it has been open
Horribly heavy box described differently after being taken
Narration which changes as the player learns new facts
*VIEWPOINT
Player controls multiple player-characters in turn
Different player characters that see different things
Description related to player preconceptions
Description varying depending on which avatar the player uses
>COMMANDS
*DESIGNING NEW COMMANDS
*WRITING NEW COMMANDS
*MODIFYING EXISTING COMMANDS
LOCK and UNLOCK with altered carrying requirements
*LOOKING
Brief descriptions by default
Full-length descriptions mandatory
*EXAMINING
EXAMINE always lists contents of containers and supporters
Adding to descriptions without using "after examining"
You see nothing special... message replaced
EXAMINE produces special results for a group of objects
Examining everything at once
*LOOKING UNDER AND HIDING
Evidence hidden until item is searched
Hiding things under other things
LOOK UNDER shows nothing unless the player has a light
SEARCH [room] action that opens every visible unlocked container
*INVENTORY
Wide and divided variations on inventory
INVENTORY listing with separate carried and worn items
INVENTORY handling of properties made more flexible
INVENTORY revised for other characters
*TAKING, DROPPING, INSERTING AND PUTTING
Scenery taking with a new message
TAKE action reports where the noun came from
DROPPING into and onto things
DROP applies even to objects the player carries indirectly
TAKE prints a description
PUT and INSERT automatically TAKE first
PUT and INSERT automatically TAKE first even with multiples
Object the player can show off without taking it first
*GOING, PUSHING THINGS IN DIRECTIONS
Pushable ball that rolls on its own
Exits listed when the player tries a wrong direction
Travel to a room described
Message on leaving a region
Falling into a pit when going from darkness to darkness
Travel with a pushed object given a new description
First look text added for a newly entered room
Traveling by room name rather than compass direction
Traveling by room name, opening doors on the way
PUSH something A DIRECTION modified
GO BACK command
GO equivalent to GO OUT
GO OUT and GO IN determine most appropriate direction if none is defined
GO UP and GO DOWN determined by room altitude
*ENTERING AND EXITING, SITTING AND STANDING
Variety of postures
GET DOWN and DOWN understood as EXIT
Automatically leaving an object before trying to travel
Automatically leaving an object before trying to take it
*OPENING, CLOSING, LOCKING AND UNLOCKING
*WAITING, SLEEPING
WAIT [number] MINUTES command
WAIT UNTIL [time] command
Sleep and waking
*MAGIC WORDS
Joke command added
*ADDITIONAL COMMAND SETS
*REMEMBERING, CONVERTING AND COMBINING ACTIONS
Redirecting actions to new objects
ASKing about a conversation topic other than the one the player typed
Characters killed off by trigger actions
Using lists as sets
Maze escaped by performing an exact sequence of actions
Device to remember and play back actions
*ACTIONS ON MULTIPLE OBJECTS
EXAMINE multiple things at once
Multiple-object actions given modified descriptions
Controlling the order in which multiple-object actions occur
GIVE extended to multiple objects at once
Allowing EXAMINE to see multiple objects with a single command
Reordering multiple objects for dramatic effect
*ALTERNATE DEFAULT MESSAGES
*CLARIFICATION AND CORRECTION
USE action which divines rational behavior for a wide range of possible nouns
Disambiguation question giving items more explicit names
Disambiguation question worded in a new way entirely
Modifying and re-parsing an entered command
Parser errors involving the any token
*ALTERNATIVES TO STANDARD PARSING
Adverbs used in commands
Keywords in place of ordinary commands
Menu of numerical options
>OTHER CHARACTERS
*GETTING ACQUAINTED
Characters and objects with titles and special articles
Characters renamed in play
People changing their titles during play
People introduced by relative
Relations applying to multiple values of the same kind
Murderer chosen randomly at start of play
*LIVELINESS
People who do new things each time the player looks
Child who asks if we're there yet
Person who picks up treasures
Every turn an opponent plays
*REACTIVE CHARACTERS
Actions prohibited in the presence of a dangerous character
Disorderly conduct
Observation stage after report
Smuggler carrying hidden items
Sleeping person who can be woken in various ways
Person who comments on the player's every action
Furniture, resentment of
*BARTER AND EXCHANGE
GIVE command extended
GIVE action for other characters
*COMBAT AND DEATH
DIAGNOSE command
Simple Randomized Combat
Randomized Combat with Weapons
Corpses left behind when a character dies
Multipart objects broken into components by gun blast
Command prompt changing to reflect state of combat
*GETTING STARTED WITH CONVERSATION
People who must be greeted before conversation
TALK TO usage corrected
*SAYING SIMPLE THINGS
ASK, TELL, and ANSWER commands rolled into one
YES and NO handled as conversation
Asking the player a Yes/No question
ASK made like SHOW when applied to objects
*SAYING COMPLICATED THINGS
Conversation system with recap of past exchanges
Conversation with multiple options for each conversation topic
TALK TO command used with scenes
Conversation based on keyword recognition
*CHARACTER EMOTION
Gestures for different characters to make during speech
Person with emotions about what is said
*CHARACTER KNOWLEDGE AND REASONING
People attempting to detect the murderer
Person who answers questions based on a common pool of knowledge
Person who answers what, where, and when questions differently
Conversation where characters seek logical connection to foregoing topics
Hints leading the player through conversation
*CHARACTERS FOLLOWING A SCRIPT
Princess who makes various remarks
Robot who records, then replays, the player's actions
Robot who tracks up to fifteen separate command scripts
Using lists as stacks
*TRAVELING CHARACTERS
Person who moves randomly
Person who moves on a pre-determined path
Person who finds a path to a destination specified by player
FOLLOW command
Person who follows the player
Multiple people's movements are collated into paragraphs
*OBEDIENT CHARACTERS
People commanded to obey
Character who learns new actions by watching the player
Person who gets fed up after being asked to do many implausible things
People who reject categories of instruction
Person who obeys almost all instructions
Issuing vague commands to characters
ASK person TO do something, understood
*GOAL-SEEKING CHARACTERS
Escape action for non-player characters only
Reporting rules for other characters' behavior
Person who opens a container before trying to get something from it
Person who pursues their own goals each turn
*SOCIAL GROUPS
People who interact with each other each turn
People listed as a group, with their possessions afterward
Shifting alliances among people
Shifting alliances demonstrating all relation types
People who move around a party on their own
Using lists as queues
>VEHICLES, ANIMALS AND FURNITURE
*BICYCLES, CARS AND BOATS
Vehicles that make noise
Car which can only be driven on roads
Travel requiring a vehicle
Description from inside a vehicle
*SHIPS, TRAINS AND ELEVATORS
An elevator operated simply by walking in and out
An elevator which takes the player to alternate floors
Shipboard directions
Train that makes station stops
*ANIMALS
Cat interacting with toys
Concealed pet who would yip at you if it could see you
Name of a dog set by the player
*FURNITURE
Drawers where thing is always in the last opened
Finding the bottom of a pile
Chest with a supporting lid
Stool, from which dropped objects fall to the floor
Raised supporter kind that conceals its contents
Basic enterable containers and supporters
Using lists as rings
*KITCHEN AND BATHROOM
Kitchen appliances
Mirror into which the player can look
>PROPS: FOOD, CLOTHING, MONEY, TOYS, BOOKS, ELECTRONICS
*FOOD
Food the player can eat without taking it first
Sanity-check stage before the Before rules
Foods with flavor
Food with ingredients affecting the player
Poisoned candy chosen randomly
Hunger eventually killing the player
*BAGS, BOTTLES, BOXES AND SAFES
Safe that can be opened with a combination
Safe with a multi-number combination
Bottles with removable stoppers
Containers referred to by contents
Object named differently if next to specific things
Object named differently if alone in its container
Letters described as a group
Containers and supporters given a common kind
*CLOTHING
Clothing kinds
Clothing that layers
Clothing with layering and regions of the body
Concealing clothing for other characters
Pocket added to every jacket
Shirts constructed from component parts
*MONEY
Money system with simple tracking of player wealth
Catalog of juggling equipment with prices
OFFER price FOR command allowing player to bargain
Money system including denominations of bills and coins
Clothes made of priced fabrics
Equation used for price curves
*DICE AND PLAYING CARDS
Deck of cards
Deck of cards with individual card objects
Deck of cards with identified poker hands
Shuffling the arrangement of items in a container
Pair of dice for rolling
*READING MATTER
Book with various contents
Book with numbered pages
Bookshelf with numerous books
Encyclopedia set
READ command separate from EXAMINE
Notebooks that can be written in
Notebooks that can be written in as a separate command line
*PAINTING AND LABELING DEVICES
Colour names for exotic pigments
Paint that colours blocks
Red sticky label
*SIMPLE MACHINES
Computer with numerous components
On/off button for devices
Signpost that can be turned
Fishing pole assembled from parts
*TELEVISIONS AND RADIOS
Radios and other devices active when switched on
Radio producing cycling programming
Television with aspect ratio
Television with channels, simple
Television with channels, advanced
*TELEPHONES
Telephones reaching distant parties
Telephones with standard American-length phone numbers
*CLOCKS AND SCIENTIFIC INSTRUMENTS
Clocks that can be SET TO any time
Telescope allowing view of another room
EMF Meter for ghost detection
*CAMERAS AND RECORDING DEVICES
Recorder that records sounds made by player and non-player actions
Camera producing instant photographs
Model objects referred to by the thing modeled
Mirror remembering a room description from the past
Video camera that records all actions
>PHYSICS: SUBSTANCES, ROPES, ENERGY AND WEIGHT
*GASES
Smoke which spreads, not tracking concentration
Diffusion of gas through the map, with concentrations
Diffusion of gas through the map, where gas sinks
*LIQUIDS
Liquid container removed when drunk
SHAKE command
Liquid which soaks into porous items
Flotation of objects
Command applying to an object added to the story
Liquid container that can be full, depleted, or empty
Liquid containers with measured contents
Fire put out by liquid
Liquids in mixtures, identified by recipe
Liquid model with large bodies of liquid added
*DISPENSERS AND SUPPLIES OF SMALL OBJECTS
Faux-infinite supply of red pens
Near-infinite supply of pizza
*GLASS AND OTHER DAMAGE-PRONE SUBSTANCES
Fragile things that break when attacked
Fragile things, basic
Fragile objects broken when things are thrown at them
Broken and unbroken flowerpots
Soft objects able to be cut open
*VOLUME, HEIGHT, WEIGHT
Weighbridge
Unit conversions
Containers that calculate internal volume and available room
Containers which have a breaking strain
Sloping landscape on which round things roll away
*ROPES
Strings referred to by their length
String that can be divided and tied together again
Rope, able to be tied to things and dragged betwixt rooms
*ELECTRICITY AND MAGNETISM
Batteries that can power devices and eventually run down
Electrified objects
Magnet which picks up nearby metal objects
*FIRE
Candle that changes as it burns down
Camp fire which can be lit using tinder
Matches that set fires
Fire that spreads
*HEAT
Supporter from which the player cannot take things
Disambiguating based on properties
Infrared goggles affect what player can see and refer to
Hot and cold objects approach room temperature
*MAGIC (BREAKING THE LAWS OF PHYSICS)
Machine that transmutes objects
Person capable of reaching through solid objects
The Pointy Hat of Liminal Transgression
Wand which reveals a person's concealed possessions
*MATHEMATICS
Using lists as arrays
Using lists as sieves
Numbers in relations
Table sorted in different ways
>PUZZLES
*EXPLORATION
*RESTRICTED AREAS AND LOCKED CONTAINERS
*MAZES, CHANGING EXITS, AND RANDOM EXITS
*RESOURCE MANAGEMENT
*TIMED PUZZLES
*PEOPLE AS BARRIERS
*REPLAYABLE AND RANDOMIZING ELEMENTS
*COMMUNICATING GOALS AND DIRECTION
>OUT OF WORLD ACTIONS AND EFFECTS
*START-UP FEATURES
Banner printing at appropriate times
Preferences file loaded on replaying
Random distribution at the start of play
*SAVING AND UNDOING
A point for never saving the game
A room where the game cannot be saved
*HELPING AND HINTING
HELP command is recommended if the player seems lost
Novice mode offers suggestions before each prompt
Responding to questions starting with WHO, WHAT, etc.
Hint access able to be turned off for the duration of the game
HELP menu from extension, with added content
HELP with a simple menu
HELP command with specific set of topics
Hints leading the player through physical puzzles
*SCORING
Scored items listed in a table
FULL SCORE using a list of stored actions
Awarding points for visiting a room
FULL SCORE with achievements table and rankings
Plot summary in place of a score
Scoreboard preserved between games
*ENDING THE STORY
Death message replaced
UNDO not mentioned in the final question
AMUSING menu shown at the endgame
Changing the final question after victory
Histories of previous games saved to external file
Resuming play after an accidental death
>TYPOGRAPHY, LAYOUT, AND MULTIMEDIA EFFECTS
*SCREEN EFFECTS (GENERAL)
*TYPOGRAPHY
HTML-style italic and boldface tags
Accented and exotic letters and symbols
Coloured letters on screen
Coloured lettering for both z-machine and Glulx
*THE STATUS LINE
Blanking the status line before play
Capitalised status line
Status line with centered text, the easy way
Status line with centered text, the hard way
Exits only listed in the status line
Exits and rooms listed in the status line
Map region listed in status line
*MENUS
*FOOTNOTES
Footnote system
*GLULX MULTIMEDIA EFFECTS
An RSS reader connecting to the Internet
>TESTING AND PUBLISHING
*TESTING
Checking for missed properties
Testing command
*PUBLISHING
Producing an EPS floorplan
Producing an EPS map of Greece
Producing an EPS map of Port Royal

View file

@ -0,0 +1,57 @@
Example: *** 3 AM
Location: New actions
RecipeLocation: Liquids
Index: SHAKE command
Description: A shake command which agitates soda and makes items thump around in boxes.
For: Z-Machine
{*}"3 AM"
Understand "shake [something preferably held]" as shaking.
Shaking is an action applying to one carried thing.
Carry out shaking:
say "Nothing results of your shaking [the noun]."
Instead of shaking a closed container when something is in the noun:
say "Something rattles inside [the noun]."
Instead of shaking a closed transparent container when something is in the noun:
say "Inside [the noun] there are banging noises produced by [the list of things contained by the noun]."
Instead of shaking an open container which contains something:
say "[The list of things contained by the noun] might fly out."
The Wawa is a room. "A convenience store, if you like to call it that, vending the usual assortment of chips, donuts, soda, and beer. There is something of a line at the sandwich counter."
The box of enrobed cakes is in the Wawa. "A box of Tastykake Enrobed Cakes has fallen off its shelf." The description is "'Enrobed Cakes' is a fancy term for 'strange sponge-like baked good, covered in a thin shell of waxy chocolate'. They are addictive, but not in a way that lets you respect yourself in the morning." The box is a closed openable container. In the box is a cake.
Instead of opening the box, say "The Wawa clerks frown on the consumption of unpurchased foodstuffs."
The can of root beer is a closed openable container carried by the player. The can of root beer is either agitated or calm.
Because the can of root beer should have some reactions to having been shaken later in the game, we need to borrow a few ideas from the chapter on Time:
{**}Instead of shaking the can of root beer:
the can calms down in five turns from now;
say "You give the can a good hard shake.";
now the can is agitated.
Instead of listening to the can: say "It sounds [if agitated]fizzy[otherwise]calm[end if]!"
At the time when the can calms down:
now the can is calm.
The sticky mess is fixed in place. "There is a sticky mess on the ground."
Instead of opening the agitated can of root beer:
now the can of root beer is nowhere;
now the sticky mess is in the location;
say "You open the can and fizzing sweet soda goes absolutely everywhere."
Instead of opening the calm can of root beer when the can has been agitated:
now the can of root beer is nowhere;
say "The root beer is disappointingly flat. That's what you get for shaking it up!"
Test me with "get box / shake box / open box / shake box / listen to can / shake can / listen to can / wait / wait / wait / wait / wait / listen to can / open can".

View file

@ -0,0 +1,69 @@
Example: ** AARP-Gnosis
Location: New activities
RecipeLocation: Reading Matter
Index: Encyclopedia set
Description: An Encyclopedia set which treats volumes in the same place as a single object, but can also be split up.
For: Z-Machine
Suppose we have a complete Encyclopedia in our game. The player is allowed to pick up the whole set (there must not be too many volumes), but also to do things with individual volumes, and indeed to scatter these volumes all over the place. Putting a volume back in the same place as the rest of the Encyclopedia should, however, restore it to the collective. We will start out by defining general rules for collectives like this:
{*}"AARP-Gnosis"
Fitting relates various things to one thing (called the home). The verb to fit means the fitting relation. Definition: a thing is missing if it is not part of the home of it.
A collective is a kind of thing.
Before doing something to something which is part of a collective:
let space be the holder of the home of the noun;
move the noun to the space.
Instead of examining a collective:
say "[The noun] consists of [the list of things which are part of the noun]."
Now the real work begins. One reason to make this an activity is that we might easily want to override it for specific objects; for instance, the generic collecting activity here would not deal properly with collectives of clothing where some items might be worn and others not. In that case, we would want to write another, more specific "collecting" activity to handle the complexities of fashion.
{**}Collecting something is an activity.
Every turn:
repeat with item running through collectives:
carry out the collecting activity with the item.
To remove (item - a thing) when empty:
let space be the holder of the item;
if the number of things which are part of the item is 0:
now the item is nowhere;
if the number of things which are part of the item is 1:
let the last thing be a random thing which is part of the item;
move the last thing to the space;
now the item is nowhere.
Before collecting a thing (called the item):
remove item when empty;
let space be the holder of the item;
if space is not a thing and space is not a room:
if something (called the other space) contains at least two things which fit the item, move item to the other space;
if a room (called the other space) contains at least two things which fit the item, move item to the other space;
if someone (called the owner) carries at least two things which fit the item, move item to the owner.
Rule for collecting a thing (called the item):
let space be the holder of the item;
if space is a thing or space is a room:
repeat with component running through things held by the space:
if the component fits the item, now the component is part of the item;
remove item when empty.
And now for a cheerful scenario:
{**}The Boise Memorial Library is a room. "A concrete box of a room, roughly eight feet by fourteen, which contains all the fallout shelter has to offer by way of entertainment. Someone with a grim sense of humor has tacked a READ! literacy poster to the door, as though there were anything else to do while you await the calming of the Geiger counters." The shelf is a supporter in the Library. "A battered utility shelf stands against the south wall."
The New Idahoan Encyclopedia Set is a collective. Volume A-Aalto fits the Encyclopedia. It is part of the Set. Volume AAM-Aardvark fits the Encyclopedia. It is part of the Set. Volume Aarhus-Aaron fits the Encyclopedia. It is part of the Set. Volume AARP-Gnosis fits the Encyclopedia. It is part of the Set. Volume Gnu-Zygote fits the Encyclopedia. It is part of the Set. The Set is on the shelf.
Let's have the Encyclopedia describe itself differently depending on whether it's all in one place:
{**}After printing the name of the Set when something missing fits the Set:
say " (missing [a list of missing things which fit the Set])"
Before printing the name of the Set when the number of missing things which fit the set is 0:
say "complete ".
Test me with "get aarhus-aaron / look / inventory / get aam-aardvark / look / get gnu-zygote / look / get aarp-gnosis / look / inventory / drop set / look / get set / get a-aalto / inventory".

View file

@ -0,0 +1,241 @@
Example: **** A Day For Fresh Sushi
Location: Repeated actions
RecipeLocation: Reactive Characters
Index: Person who comments on the player's every action
Description: A complete story by Emily Short, called "A Day for Fresh Sushi", rewritten using Inform 7. Noteworthy is the snarky commenter who remarks on everything the player does, but only the first time each action is performed.
For: Z-Machine
The following is an almost-completely-faithful rewrite of Emily Short's "A Day for Fresh Sushi", which was originally written using the (very different) Inform 6 programming language. The -- let us be honest and call it a gimmick -- of this game is the evil fish, who has some unpleasant remark to offer on pretty much every action. But the effect would wear off fast if he repeated himself, so these comments need to be single-use only.
Inform 7's repeated action syntax makes it much tidier to write the same scenario, so:
{*}"A Day For Fresh Sushi" by Emily Short.
Use scoring.
The story headline is "Your basic surreal gay fish romance".
The Studio is a room. "[if visited]Decorated with Britney's signature flair. It was her innate sense of style that first made you forgive her that ludicrous name. And here it is displayed to the fullest: deep-hued drapes on the walls, the windows flung open with their stunning view of old Vienna, the faint smell of coffee that clings to everything. Her easel stands over by the windows, where the light is brightest.[otherwise]This is Britney's studio. You haven't been around here for a while, because of how busy you've been with work, and she's made a few changes -- the aquarium in the corner, for instance. But it still brings back a certain emotional sweetness from the days when you had just met for the first time... when you used to spend hours on the sofa...
You shake your head. No time for fantasy. Must feed fish.[end if]"
Instead of smelling the Studio:
say "The evil fish notices you sniffing the air. 'Vanilla Raspberry Roast,' it remarks. 'You really miss her, don't you.'
You glance over, startled, but the fish's mouth is open in a piscine equivalent of a laugh. You stifle the urge to skewer the thing..."
Instead of jumping:
say "'Er,' says the fish. 'Does that, like, EVER help??'"
Instead of going nowhere:
say "You can't leave until you've fed the fish. Otherwise, he'll complain, and you will never hear the end of it."
The cabinet is an openable closed container in the Studio. It is fixed in place. "A huge cabinet, in the guise of an armoire, stands between the windows." The description is "Large, and with a bit of an Art Nouveau theme going on in the shape of the doors." Understand "armoire" as the cabinet.
Instead of looking under the cabinet for the first time:
say "'Dustbunnies,' predicts the fish, with telling accuracy. It executes what for all the world looks like a fishy shudder. 'Lemme tell you, one time I accidentally flopped outta the tank, and I was TWO HOURS on the floor with those things STARING ME IN THE NOSE. It was frightening.'"
After opening the cabinet for the first time:
say "'There ya go,' says the fish. 'The girl is getting WARMER.'"
After closing the cabinet for the first time:
if the fish food is not found, say "'Ooh, what do you think, Bob? I think we're going to have to dock the girl a few points. HAVE ANOTHER LOOK, sweetcakes, there's a doll.'"
The cabinet contains some paints and some cloths. The description of the paints is "A bunch of tubes of oil paint, most of them in some state of grunginess, some with the tops twisted partway off."
After taking the paints for the first time:
say "'Boy,' says the fish, apparently to himself, 'I sure hope that's some food she's finding for me in there. You know, the yummy food in the ORANGE CAN.'"
After examining the paints for the first time:
say "'Tons of useful stuff in there,' hollers in the fish, in a syncopated burble."
The description of the cloths is "Various colors of drapery that Britney uses to set up backgrounds and clothe her models. She does a lot of portraiture, so this comes in handy. It's all a big messy wad at the moment. Organized is not her middle name." Understand "drapery" or "cloth" as the cloths. The indefinite article of the cloths is "a heap of". [see 3.17]
Instead of searching or looking under the cloths for the first time:
now the player is carrying the fish food;
now the fish food is found;
say "Poking around the cloths reveals -- ha HA! -- a vehemently orange can of fish food."
Instead of showing the cloths to the fish:
say "'What are you, some kind of sadist? I don't want to see a bunch of cloths! What kind of f'ing good, 'scuse my French, is that supposed to do me? I don't even wear pants for God's sake!'
He really looks upset. You start wondering whether apoplexy is an ailment common to fish."
After examining cloths for the first time:
say "'Whatcha looking at? I can't see through the doors, you know.'"
There is a can of fish food. Understand "canister" as the can. The description is "A vehemently orange canister of fish food." The fish food can be found or hidden. The fish food is hidden.
Instead of giving the can to the fish:
say "'I don't want the whole can, GeniusChyk. Just feed me and we'll ALL be happy, 'kay?"
Instead of showing the can to the fish:
say "'That's the ticket, sweetie! Bring it on.'"
Instead of opening the can:
say "'Oh, for--!' The evil fish breaks out in exasperation and hives. 'Screw the screwing around with the screwtop. SHE never has to do that.'
'Well, SHE is not here,' you reply. 'What do you suggest?'
'>FEED FISH<' says the fish promptly, making fishy faces and pointing at you with his fin. 'Simplicity. Try it.'"
Instead of inserting the can into something:
say "'HelLLLOOO,' screams the fish. 'Whatever happened to FEEDING MEEE?'"
The easel is a supporter in the Studio. It is scenery. On the easel is a painting. Understand "portrait" or "image" as the painting.
The description of the painting is "Only partway finished, but you can tell what it is: Britney's mother. You only met the old woman once, before she faded out of existence in a little hospice in Salzburg.
In the picture, her hands are grasping tightly at a small grey bottle, the pills to which she became addicted in her old age, and strange, gargoyle-like forms clutch at her arms and whisper in her ears.
But the disturbing thing, the truly awful thing, is the small figure of Britney herself, down in the corner, unmistakable: she is walking away. Her back turned.
You thought she'd finally talked this out, but evidently not. Still feels guilty for leaving. You only barely stop yourself from tracing, with your finger, those tiny slumped shoulders..."
Instead of taking the painting, say "No, you'd better leave it. It'd freak her out if you moved it."
Before examining the painting for the first time:
say "A ferocious banging from the aquarium attracts your attention as you go to look at the painting. 'Hey!' screams the fish. 'She doesn't like strangers looking at her paintings before they're DOONNNE!'
'Shut up, you,' you reply casually. 'I'm not a stranger.' But the fish puts you off a little bit, and your heart is already in your mouth before you see the painting itself...".
Instead of examining the painting more than once:
say "Once is really enough. It's pretty much embedded in your consciousness now."
After doing something to the painting:
say "'So what's it of?' asks the fish, as you turn away. 'She never asks if I want to see them, you know?'
'Her mother,' you respond without thinking.
'Yeah? Man. I never knew my mother. Eggs, that's the way to go.'"
The window is scenery in the Studio. The window can be openable. The window can be open. It is openable and closed. Understand "windows" as the window. The description of the window is "[if open]Through the windows you get a lovely view of the street outside. At the moment, the glass is thrown open, and a light breeze is blowing through.[otherwise]Through the windows, you get a lovely view of the street outside -- the little fountain on the corner, the slightly dilapidated but nonetheless magnificent Jugendstil architecture of the facing building. The glass itself is shut, however.[end if]"
After opening the window for the first time:
say "'Thank god some air,' says the fish. 'Man, it was getting hard to breathe in here.' Two beats pass. 'Oh wait.'"
The table is scenery in the Studio. On the table is a vase. The vase is an open container. It is not openable.
The description of the table is "A monstrosity of poor taste and bad design: made of some heavy, French-empire sort of wood, with a single pillar for a central leg, carved in the image of Poseidon surrounded by nymphs. It's all scaley, and whenever you sit down, the trident has a tendency to stab you in the knee. But Britney assures you it's worth a fortune." The description of the vase is "A huge vase -- what you saw once described in a Regency romance as an epergne, maybe -- something so big that it would block someone sitting at the table from seeing anyone else also sitting at the table. But it does function nicely as a receptacle for hugeass bouquets of flowers."
Instead of looking under the table for the first time:
say "'You're not going to find anything down there,' whines the fish. 'I mean, c'mon. It's the fricking floor. Please tell me you can see that. I can see that. I'm a myopic fish in a tank ten feet away and I can tell you there is nothing there but floor.'"
After examining the table:
say "'That there is MY PA,' says the fish, pointing at the scaley triton figure with one fin."
Instead of inserting something which is not the bouquet into the vase:
say "'Okay, so, what were you, raised in a barn? Normal folks like to use that for flowers. Or so I've observed.'"
After inserting the bouquet into the vase for the first time:
say "You settle the flowers into the vase and arrange them so that they look sprightly.
'Oooh,' says the fish. 'No one ever changes the plant life in HERE. It's the same seaw--'
'Cut me a break and cork it,' you reply tartly."
The player is carrying a telegram, a bouquet, and a lingerie bag. The player is wearing a chef hat.
The description of the telegram is "A telegram, apparently. And dated three days ago. [fixed letter spacing]TRIUMPH OURS STOP BACK SOON STOP BE SURE TO FEED FISH STOP[variable letter spacing]". [For printing options see 4.13.] Understand "yellow paper" as the telegram.
After examining the telegram for the first time:
say "'So,' blubs the evil fish. 'How about it? Little food over here?'"
After examining the telegram:
choose a random row in the Table of Insulting Fish Comments;
say "[comment entry][paragraph break]".
Table of Insulting Fish Comments
comment
"'Yeah, yeah,' says the fish. 'You having some trouble with the message, there? Confused? Something I could clear up for you?'"
"'Oookay, genius kid has some troubles in the reading comprehension department.' The fish taps his head meaningfully against the side of the tank. 'I'm so hungry I could eat my way out, you get my meaning?'"
"'I'll translate for you,' screams the fish in toothy fury. 'It says GIVE FOOD TO FISH!! How much more HELP do you NEED???"
The description of the chef hat is "A big white chef hat of the kind worn by chefs. In this case, you. Just goes to show what a hurry you were in on the way out of the restaurant." Understand "big" or "white" or "chefs" or "chef's" as the chef hat. [Inform knows that this is clothing because the player starts out wearing it, so there's no need to say so separately.]
The aquarium is a transparent open container in the Studio. It is not openable. "In one corner of the room, a large aquarium bubbles in menacing fashion." The description of the aquarium is "A very roomy aquarium, large enough to hold quite a variety of colorful sealife -- if any yet survived." Understand "tank" as the aquarium.
The aquarium contains some gravel and some seaweed. Understand "little rocks" as the gravel. Understand "weed" as the seaweed. The description of the gravel is "A lot of very small grey rocks." The description of the seaweed is "Fake plastic seaweed of the kind generally bought in stores for exactly this purpose."
The examine containers rule does nothing when examining the aquarium.
After examining the gravel for the first time:
say "The fish notices your gaze; makes a pathetic mime of trying to find little flakes of remaining food amongst the gravel."
After examining the seaweed for the first time:
say "'Nice, hunh?' blubs the fish, taking a stabbing bite out of one just by way of demonstration. 'Look so good I could eat it.'"
The aquarium contains an animal called an evil fish. The description of the fish is "Even if you had had no prior experience with him, you would be able to see at a glance that this is an evil fish. From his sharkish nose to his razor fins, every inch of his compact body exudes hatred and danger."
Instead of taking the evil fish:
say "The fish swims adroitly out of range of your bare hand. 'Hey,' he says, and the bubbles of his breath brush against your fingers. 'Count yourself lucky I don't bite you right now, you stinking mammal.'"
Instead of attacking the evil fish:
say "Oh, it's tempting. But it would get you in a world of hurt later on."
Instead of kissing the evil fish:
say "You're saving all your lovin for someone a lot cuddlier."
After examining the evil fish for the first time:
say "The fish glares at you, as though to underline this point."
After examining the evil fish for the second time:
say "'If you're looking for signs of malnutrition,' says the fish, 'LOOK NO FURTHER!!' And it sucks in its gills until you can see its ribcage."
An every turn rule:
choose a random row in the Table of Fish Banter;
say "[comment entry][paragraph break]".
Table of Fish Banter
comment used
"'Hey, nice SKIN TONE,' shouts the evil fish. His words reach you in a spitting gurgle of aquarium water. 'You gone over to a pure eggplant diet these days?'" 0
"The evil fish is floating belly up! ...oh, curse. He was toying with you. As soon as he sees you looking, he goes back to swimming around." 0
"The evil fish darts to the bottom of the tank and moves the gravel around with his nose." 0
"The evil fish is swimming around the tank in lazy circles." 0
"The evil fish begins to butt his pointy nose against the glass walls of the tank." 0
The description of the bouquet is "Okay, so it's silly and sentimental and no doubt a waste of money, of which there is never really enough, but: you miss her. You've missed her since ten seconds after she stepped aboard the shuttle to Luna Prime, and when you saw these -- her favorites, pure golden tulips like springtime -- you had to have them." Understand "flowers" or "tulip" or "tulips" as the bouquet.
After examining the bouquet for the first time:
say "'Oh, you shouldn't have,' says the fish. 'For me??'
You just respond with a livid glare."
Instead of smelling the bouquet for the first time:
say "'Mmm-mm,' says the fish. 'Damn, I sure wish I had olfactory abilities. Hey, if I did, I might be even better at noticing the presence or absence of FOOD.'"
The description of the lingerie bag is "You grant yourself the satisfaction of a little peek inside. You went with a pale, silky ivory this time -- it has that kind of sophisticated innocence, and it goes well with the purple of your skin. A small smirk of anticipation crosses your lips."
After examining the lingerie bag for the first time:
say "'What's in THERE?' asks the fish. 'Didja bring me take-out? I don't mind Chinese. They eat a lot of carp, but what do I care? I'm not a carp. Live and let live is what I s--'
'It's NOT take-out.' You stare the fish down and for once he actually backstrokes a stroke or two. 'It's PRIVATE.'"
After examining the lingerie bag for the second time:
say "'If it's not take-out, I don't see the relevance!' shouts the fish. 'Food is what you want in this situation. Food for MEEEE.'"
Understand the command "feed" as something new.
Understand "feed [something]" as feeding.
Feeding is an action applying to one visible thing.
Check feeding:
if the noun is not the evil fish, say "That doesn't make much sense." instead;
if the player is not carrying the fish food, say "You need the fish food first." instead.
Carry out feeding:
increment the score;
say "Triumphantly, you dump the remaining contents of the canister of fish food into the tank. It floats on the surface like scum, but the fish for once stops jawing and starts eating. Like a normal fish. Blub, blub.[paragraph break]";
say "[bold type] *** TWO HOURS LATER ***[roman type][paragraph break]'So,' Britney says, tucking a strand of hair behind your ear, 'where shall we go for dinner? Since I made the big bucks on this trip, it's my treat. Anywhere you like.'[paragraph break]'I've had a hankering all day,' you admit, as the two of you turn from the shuttle platform and head toward the bank of taxis. 'I could really go for some sashimi right now.'";
end the story finally.
Before feeding the fish food:
try feeding the evil fish instead.
When play begins:
say "You're on the run. You've got a million errands to do -- your apartment to get cleaned up, the fish to feed, lingerie to buy, Britney's shuttle to meet-- [paragraph break]The fish. You almost forgot. And it's in the studio, halfway across town from anywhere else you have to do. Oh well, you'll just zip over, take care of it, and hop back on the El. This'll be over in no time.[paragraph break]Don't you just hate days where you wake up the wrong color?[paragraph break]".
The maximum score is 1.
Test me with "x fish / g / kiss fish / x aquarium / x gravel / x seaweed / i / x telegram / x bouquet / smell bouquet / x lingerie / g / x hat / x window / open window / x painting / g / x cabinet / open cabinet / x cloths / search cloths / open food / feed fish".

View file

@ -0,0 +1,24 @@
Example: ** A&E
Location: Going from, going to
RecipeLocation: Map
Index: Region off-limits to a player without VIP pass
Description: Using regions to block access to an entire area when the player does not carry a pass, regardless of which entrance they use.
For: Z-Machine
Rules about going to regions make it easy to exclude the player from a large portion of the map, even if there are many connecting paths to the region. For instance, in this story it would be annoying to have to write a rule about all four exits by which the player could reach the film set area:
{*}"A&E"
Winding Street is a room. Winding Street is west of Duck Pond. Sloping Street is north of Winding Street, northwest of Duck Pond, west of Stately Lawn, and southwest of Stately Home. Stately Lawn is north of Duck Pond. Stately Home is north of Stately Lawn.
Film Set is a region. Duck Pond, Stately Lawn, and Stately Home are in Film Set.
Instead of going to Film Set when the player does not carry the VIP Pass: say "A burly studio guard materializes in your path, convincing you that you would prefer to be elsewhere."
The VIP Pass is in the garbage can. The garbage can is in Sloping Street.
After going to the Film Set:
say "Success! At last you are inside the set of 'Prouder and More Prejudiced'. Next step: locating Mr Firth.";
end the story finally.
Test me with "e / n / e / get pass / e".

View file

@ -0,0 +1,59 @@
Example: *** A Haughty Spirit
Location: Phrases to decide other things
RecipeLocation: Windows
Index: Windows in high places
Description: Windows overlooking lower spaces which will prevent the player from climbing through if the lower space is too far below.
For: Z-Machine
Suppose we have a game in which the player can climb through windows which overlook rooms below. We want them to be allowed to climb out windows to reach a room on the same level or at most one level lower than the one they're on; otherwise, they should get a refusal, saying that they would break their neck.
To figure out the height distance between the start room and the destination room, we might have a repeat loop look at all the directions one has to follow along the "best route" path between the two rooms, and record any ups and downs; then subtract the number of "up" steps from the number of "down" steps, and report what remains.
{*}"A Haughty Spirit"
To decide what number is the distance (first place - a room) rises above (second place - a room):
let the total distance be the number of moves from the first place to the second place;
if the total distance is less than 1, decide on 0;
let count of down moves be 0;
let count of up moves be 0;
let next place be the first place;
repeat with counter running from 1 to the total distance:
let the way be the best route from the next place to the second place;
if the way is down, let count of down moves be the count of down moves plus 1;
if the way is up, let the count of up moves be the count of up moves plus 1;
let next place be the room the way from next place;
let the decision be the count of down moves minus the count of up moves;
decide on the decision.
Now we just have to create windows and some action rules for interacting with them...
{**}A window is a kind of thing. A window is always fixed in place. A window can be open or closed. A window is usually closed. A window can be openable or unopenable. A window is usually openable.
Understand "climb through [something]" as entering. Understand "jump through/out [something]" as entering.
Before entering a closed window:
say "[The noun] would have to be opened first." instead.
Instead of entering a window:
if the noun overlooks a room (called the far side):
let fall be the distance the location rises above the far side;
if fall is greater than 1, say "You'd break your neck." instead;
say "You tumble into [the far side].";
move the player to the far side;
otherwise:
say "There's nowhere to go."
Instead of examining a window:
say "[The noun] [if the noun is open]opens over[otherwise]gives a view of[end if] [the list of rooms overlooked by the noun]."
Here we must anticipate a little from the chapter on Relations, and provide ourselves with a way of keeping track of how windows and rooms relate to one another:
{**}Overlooking relates various windows to various rooms. The verb to overlook means the overlooking relation. The initial appearance of a window is usually "[The item described] overlooks [the list of rooms overlooked by the item described]."
The Square Keep is above the Winding Staircase. The Winding Staircase is above the Motte. A crown and a broken sword are in the Motte. The Bailey is west of the Motte.
The long window is in the Keep. The long window overlooks the Bailey and the Motte. The narrow window is in the Winding Staircase. The narrow window overlooks the Bailey.
Test me with "jump through window / open window / jump through window / d / x narrow window / open window / climb through window / e / up / down".
We could then add rules to allow the player to look through windows and see things in the rooms below, but that would require more material from later chapters.

View file

@ -0,0 +1,49 @@
Example: *** A Humble Wayside Flower
Location: Relations which express conditions
RecipeLocation: Getting Acquainted
Index: People introduced by relative
Description: Relations track the relationships between one character and another. Whenever the player meets a relative of someone they already know, they receive a brief introduction.
For: Z-Machine
First we define the relationships we choose to acknowledge:
{*}"A Humble Wayside Flower"
Marriage relates one person to another (called the spouse). The verb to be married to means the marriage relation.
Fatherhood relates one person (called father) to various people. The verb to engender means the fatherhood relation.
For brevity, we will ignore the existence of mothers. It is a sad world.
{**}Siblinghood relates a person (called A) to a person (called B) when a person who engenders A engenders B. The verb to be sibling to means the siblinghood relation.
Family relates a person (called A) to a person (called B) when A is married to B or A engenders B or B engenders A or A is sibling to B. The verb to be related to means the family relation.
A person can be known or unknown. After printing the name of an unknown person (called the alien):
if a known person (called the contact) is related to the alien:
say " ([relation between alien and contact] of [the contact])";
now the alien is known;
rule succeeds.
To say relation between (first party - a person) and (second party - a person):
if the first party is married to the second party:
if the first party is female, say "wife";
otherwise say "husband";
rule succeeds;
if the first party is sibling to the second party:
if the first party is female, say "sister";
otherwise say "brother";
rule succeeds;
if the first party engenders the second party:
say "father";
rule succeeds;
if the second party is the father of the first party:
if the first party is female, say "daughter";
otherwise say "son";
rule succeeds.
Pere Blanchard's Hut is a room. Percival Blakeney is a known man in the Hut. Marguerite is a woman in the Hut. Percival is married to Marguerite. Outside from the Hut is the Garden. Louise is a woman in the Garden. The Road to Paris is west of the Garden. Armand St Just is a man in the Road. Louise is married to Armand. Monsieur St Just is a man. He engenders Armand and Marguerite.
Test me with "out / west / east / west".
Monsieur St Just never appears on the scene in this piece, but if we did put him somewhere the player could find him, he, too, would be properly introduced.

View file

@ -0,0 +1,19 @@
Example: *** A point for never saving the game
Location: Out of world actions
RecipeLocation: Saving and Undoing
Index: A point for never saving the game
Description: In some of the late 1970s "cave crawl" adventure games, an elaborate scoring system might still leave the player perplexed as to why an apparently perfect play-through resulted in a score which was still one point short of the supposed maximum. Why only 349 out of 350? The answer varied, but sometimes the last point was earned by never saving the game - in other words by playing it right through with nothing to guard against mistakes (except perhaps UNDO for the last command), and in one long session.
For: Z-Machine
Here is one way to score this point with Inform:
Check saving the game for the first time: decrement the score.
That has the right effect, but it just isn't sneaky enough. Instead let us quietly keep track of how many times the player saves:
Check saving the game: increment the number of saves.
When play ends: if the number of saves is 0, increment the score.
Sneakier, certainly, but now we could get the bonus even if the game ends earlier on, so finally:
When play ends: if the number of saves is 0 and the score is 349, increment the score.

View file

@ -0,0 +1,42 @@
Example: *** A View of Green Hills
Location: Adjacent rooms and routes through the map
RecipeLocation: Continuous Spaces and The Outdoors
Index: LOOK [direction] command
Description: A LOOK [direction] command which allows the player to see descriptions of the nearby landscape.
For: Z-Machine
Suppose a game in which the player is wandering an open landscape with long vistas, allowing them to LOOK in some direction, or even look at an adjacent location.
{*}"A View of Green Hills"
Corinth is a room. Athens is east of Corinth. Epidaurus is southeast of Corinth and east of Mycenae. Mycenae is south of Corinth. Olympia is west of Mycenae. Argos is south of Mycenae. Thebes is northwest of Athens. Pylos is south of Olympia. Sparta is east of Pylos and south of Argos. Delphi is northwest of Thebes.
Understand "look [direction]" as facing.
Facing is an action applying to one visible thing.
Carry out facing:
let the viewed item be the room noun from the location;
if the viewed item is not a room, say "You can't see anything promising that way." instead;
try looking toward the viewed item.
In rules about action handling, "noun" refers to the first object that the player has mentioned in their command, so if the player typed >LOOK WEST, "let the viewed item be the room noun from the location" would be processed as "let the viewed item be the room west from the location", and so on.
We can at need override the default behavior, if it is not going to be appropriate for the player to see the next room over. There is only sky above at any time, so...
{**}Instead of facing up:
say "Above you is bright sky."
Understand "look toward [any adjacent room]" as looking toward. Understand "examine [any adjacent room]" as looking toward.
Looking toward is an action applying to one visible thing.
Carry out looking toward:
say "You make out [the noun] that way."
This design allows us to create descriptions for rooms (as seen from the outside) which will work regardless of where we're looking from. For instance:
{**}Instead of looking toward Athens:
say "Even from here you can make out the silhouette of the Acropolis."
Test me with "look north / look south / look up / look east / east / look west".

View file

@ -1,286 +0,0 @@
* Defining new prepositions
(Relations syntax explored--Shifting alliances demonstrating all relation types; The Abolition of Love)
A thorough exploration of all the kinds of relations established so far, with the syntax to set and unset them.
Suppose we are modeling a complex society seething with interpersonal relations of every kind.
{*}"The Abolition of Love"
Section 1 - Relation types
Loving relates one person to one person.
Noticing relates various people to one person.
Impressing relates one person to various people.
Fancying relates various people to various people.
Acquaintance relates people to each other.
Marriage relates one person to another.
Alliance relates people to each other in groups.
The Chapel is a room. Elizabeth, Wickham and Darcy are people in the Chapel. Mr Bennett and Mrs Bennett are people in the Chapel. Georgiana is a person in the Chapel.
The verb to love means the loving relation.
The verb to notice means the noticing relation.
The verb to impress means the impressing relation.
The verb to fancy means the fancying relation.
The verb to know means the acquaintance relation.
The verb to be married to means the marriage relation.
The verb to be related to means the alliance relation.
Elizabeth loves Darcy. Elizabeth fancies Darcy. Elizabeth notices Darcy. Elizabeth impresses Darcy.
Mr Bennett is related to Mrs Bennett and Elizabeth. Mr Bennett is married to Mrs Bennett.
Georgiana is related to Darcy.
Now we want ways to set and unset all of these relations. (In the interests of thoroughness, we may get a bit far-fetched here. It is not recommended in practice that we make the player guess the verb "traduce".)
{**}Section 2 - Setting and Unsetting Love (1-1)
Understand "infatuate [someone] with [someone]" as infatuating it with. Infatuating it with is an action applying to two visible things.
Carry out infatuating it with:
now the noun loves the second noun.
Report infatuating it with:
say "Now [the noun] loves [a random person loved by the noun][if the second noun loves someone], while [the second noun] loves [a random person loved by the second noun][end if]."
Understand "embitter [someone] toward [someone]" as embittering it toward. Embittering it toward is an action applying to two visible things.
Carry out embittering it toward:
now the noun does not love the second noun.
Report embittering it toward:
say "[The noun] sees [the second noun] in a different light and no longer feels any affection."
Because love is a 1-1 relation, a person cannot love more than one other character at a time. Whenever we set a character to love a new person, that person ceases to love the character loved before. It is a fickle world.
One to various relations are a bit more open: we can say someone impresses multiple other characters, and our additions to the list do not override the initial ones.
{**}Section 3 - Setting and Unsetting Impressed (1-V)
Understand "commend [someone] to [someone]" as commending it to. Commending it to is an action applying to two visible things.
Carry out commending it to:
now the noun impresses the second noun.
Report commending it to:
say "[The second noun] takes a very decided interest in [the noun]."
Understand "traduce [someone] to [someone]" as traducing it to. Traducing it to is an action applying to two visible things.
Carry out traducing it to:
now the noun does not impress the second noun.
Report traducing it to:
say "[The second noun], hearing your story, decides not to be at all impressed with [the noun]."
And because this is a one-to-various relation, we can also make statements which set multiple relations at once, so:
{**}Understand "celebrate [someone]" as celebrating. Celebrating is an action applying to one visible thing.
Carry out celebrating:
now the noun impresses every person.
Report celebrating:
say "[The list of people who are impressed by the noun] take a very decided interest in [the noun]."
Understand "slander [someone]" as slandering to. Slandering to is an action applying to one visible thing.
Carry out slandering to:
now every person is not impressed by the noun.
Report slandering to:
say "Now [the noun] impresses [the list of people who are impressed by the noun]."
Note that the above unsetting is not equivalent to "now the noun does not impress every person" -- which would be ambiguous in spoken English, as well. Various-to-one relations are similar:
{**}Section 4 - Setting and Unsetting Noticing (V-1)
Understand "draw the attention of [someone] to [someone]" as drawing the attention of it to. Drawing the attention of it to is an action applying to two visible things.
Carry out drawing the attention of it to:
now the noun notices the second noun.
Report drawing the attention of it to:
say "[The noun] glances thoughtfully in the direction of [the second noun]."
Understand "distract [someone] from [someone]" as distracting it from. Distracting it from is an action applying to two visible things.
Carry out distracting it from:
now the noun does not notice the second noun.
Report distracting it from:
say "You distract [the noun] from [the second noun]."
Understand "draw attention to [someone]" as drawing attention to. Drawing attention to is an action applying to one visible thing.
Carry out drawing attention to:
now every person notices the noun.
Report drawing attention to:
say "You quickly cause everyone to attend to [the noun]."
Understand "outshine [someone]" as outshining. Outshining is an action applying to one visible thing.
Carry out outshining:
now every person does not notice the noun.
Report outshining:
say "You quickly distract everyone from [the noun]."
Section 5 - Setting and Unsetting Fancying (V-V)
Understand "flatter [someone]" as flattering. Flattering is an action applying to one thing.
Carry out flattering:
now every person fancies the noun.
Report flattering:
say "You draw down universal admiration for [the noun] by casting them in a flattering light."
Understand "unflatter [someone]" as unflattering. [Okay, okay, but it's four am.] Unflattering is an action applying to one thing.
Carry out unflattering:
now every person does not fancy the noun.
Report unflattering:
say "[The noun] gives everyone a universal disgust."
Understand "admire [someone]" as admiring. Admiring is an action applying to one thing.
Carry out admiring: now the player fancies the noun.
Report admiring: say "You find you rather fancy [the noun]."
Understand "loathe [someone]" as loathing. Loathing is an action applying to one thing.
Carry out loathing: now the player does not fancy the noun.
Report loathing: say "You take [the noun] in disgust."
Understand "cause chaos" as causing chaos. Causing chaos is an action applying to nothing.
Carry out causing chaos:
now every person fancies every person.
Report causing chaos: say "Now everyone fancies everyone else, which is quite an inconvenient state of affairs."
Understand "relieve chaos" as relieving chaos. Relieving chaos is an action applying to nothing.
Carry out relieving chaos:
now every person is fancied by no one.
Report relieving chaos: say "Now no one fancies anyone, which is safe but tedious."
Our options for setting and unsetting symmetrical relations are more limited again:
{**}Section 6 - Setting and Unsetting Marriage (1-1 Symmetrical)
Understand "marry [someone] to [someone]" as uniting it in matrimony with. Uniting it in matrimony with is an action applying to two visible things.
Carry out uniting it in matrimony with:
now the noun is married to the second noun.
Report uniting it in matrimony with:
say "You perform the marriage of [the noun] to [the second noun], joining them to the family of [a list of people related to the noun]."
Understand "divorce [someone] from [someone]" as divorcing it from. Divorcing it from is an action applying to two visible things.
Check divorcing it from:
if the noun is not married to the second noun, say "[The noun] is not married to [the second noun] anyway." instead.
Carry out divorcing it from:
now the noun is not married to the second noun.
Report divorcing it from:
say "[The noun] is now not married to [the second noun]."
When we unset the symmetrical relation on one side, it is automatically set or unset on the other. It is not necessary to say "the second noun is married to the noun" or "the second noun is not married to the noun", even though that is the case.
{**}Section 7 - Setting and Unsetting Acquaintance (V-V Symmetrical)
Understand "introduce [someone] to [someone]" as introducing it to. Introducing it to is an action applying to two visible things.
Carry out introducing it to:
now the noun knows the second noun.
Report introducing it to:
say "You introduce [the noun] to [the second noun]. Now [the noun] is acquainted with [the list of people who are known by the noun], and [the second noun] is acquainted with [the list of people who are known by the second noun]."
Understand "announce [someone]" as announcing. Announcing is an action applying to one visible thing.
Carry out announcing:
now every person knows the noun.
Report announcing:
say "You announce [the noun] to the whole assembled company."
Understand "ostracise [someone]" as ostracising. Ostracising is an action applying to one visible thing.
Carry out ostracising:
now every person does not know the noun.
Report ostracising:
say "You cause everyone present to forget and pretend not to be acquainted at all with [the noun]."
And finally, setting groups:
{**}Section 8 - Setting and Unsetting Familial Relations (Groups)
Understand "make [someone] adopt [someone]" as forcing it to adopt. Forcing it to adopt is an action applying to two visible things.
Carry out forcing it to adopt:
now the noun is related to the second noun.
Report forcing it to adopt:
say "Now [the second noun] is related to [the list of people related to the second noun]."
Understand "make [someone] disown [someone]" as forcing it to disown. Forcing it to disown is an action applying to two visible things.
Carry out forcing it to disown:
now the second noun is not related to the noun.
Report forcing it to disown:
say "Now [the second noun] is related to [the list of people who are related to the second noun], and [the noun] is related to [the list of people who are related to the noun]."
Notice that when we say "the second noun is not related", we remove that person from the group: they are now in a separate group of their own, while the rest of the group's members remain related to one another.
And finally, a long litany of test cases, complete with the relations lists:
{**}Test acquaintance with "relations / introduce darcy to elizabeth / introduce darcy to wickham / announce mr bennett / relations / ostracise wickham / introduce georgiana to wickham / relations".
Test impression with "commend georgiana to elizabeth / relations / celebrate Mrs bennett / relations / traduce mrs bennett to darcy / relations / slander mrs bennett / relations".
Test notice with "draw the attention of darcy to elizabeth / relations / draw attention to mr bennett / relations / distract darcy from mr bennett / relations / outshine mr bennett / relations".
Test love with "embitter elizabeth toward darcy / relations / infatuate elizabeth with wickham / relations".
Test marriage with "marry elizabeth to darcy / relations / divorce elizabeth from darcy / relations".
Test alliance with "make mr bennett adopt georgiana / relations / make mrs bennett disown georgiana / relations".
Test fancying with "admire elizabeth / relations / loathe elizabeth / relations / flatter elizabeth / relations / unflatter elizabeth / relations / cause chaos / relations / relieve chaos / relations".
Test me with "test acquaintance / test impression / test notice / test love / test alliance / test fancying / test marriage".

View file

@ -0,0 +1,40 @@
Example: * About Inform's regular expression support
Location: Regular expression matching
RecipeLocation: Information Only
Index: About Inform's regular expression support
Description: Some footnotes on Inform's regular expressions, and how they compare to those of other programming languages.
For: Z-Machine
There is not really any unanimity about what regular expression language is. The unix tools sed and grep extend on Kleene's original grammar. Henry Spencer's regex library extended on this again, and was a foundation for Perl, but Perl once again went further. Philip Hazel's PCRE, despite the name Perl Compatible Regular Expressions, makes further extensions still, and so on.
Inform's regular expressions are modelled on those of Perl, as the best de facto standard we have, but a few omissions have been inevitable. Inform's regex matcher must occupy source code less than one hundredth the size of PCRE, and it has very little memory. Inform aims to behave exactly like Perl except as follows:
(i) Inform allows angle brackets as synonymous with square brackets, for reasons explained above. This means literal angle brackets have to be escaped as "\<" and "\>" in Inform regular expressions, which is unnecessary in Perl.
(ii) Inform only has single-line mode, not multiline mode: this removes need for the mode-switches "(?m)" and "(?s)" and the positional markers "\A" and "\Z". Multiline mode is idiosyncratic to Perl and is a messy compromise to do with holding long files of text as single strings, yet treating them as lists of lines at the same time: this would not be sensible for Inform. Similarly, because there is no ambiguity about how line breaks are represented in Inform strings (by a single "\n"), initial newline convention markers such as "(*ANYCRLF)" are unsupported.
(iii) The codes "\a", "\r", "\f", "\e", "\0" for alarm, carriage return, form feed, escape and the zero character are unsupported: none of these can occur in an Inform string.
(iv) Inform does not allow characters to be referred to by character code (whereas Perl allows "\036" for an octal character code, "\x7e" for a hexadecimal one, "\cD" for a control character). This is because we do not want the user to know whether text is internally stored as ZSCII or Unicode.
(v) Inform's character class "\p" (and its negation "\P") have no equivalent in Perl, and Inform's understanding of "\w" is different. Perl defines this as an upper or lower case English letter, underscore or digit, which is good for programming-language identifiers, but bad for natural language - for instance, "é" is not matched by "\w" in Perl, but unquestionably it appears in words. Inform therefore defines "\w" as the negation of "\s" union "\p".
(vi) Inform supports only single-digit grouping numbers "\1" to "\9", whereas Perl allows "\10", "\11", ...
(vii) POSIX named character ranges are not supported. These are only abbreviations in any case, and are not very useful. (Note that the POSIX range "[:punct:]", which is supposedly for punctuation, includes many things we do not want to think of that way - percentage signs, for instance - and so "\p" has a more natural-language-based definition.)
(viii) Character classes can be used inside ranges, so that "<\da-f>" is legal, but not as ends of contiguous runs, so that "<\d-X>" is not legal. (As reckless as this is, it is legal in Perl.)
(ix) For obvious reasons, escapes to Perl code using the notation "(?{...})" are unsupported, and so is the Perl iteration operator "\G".
(x) Perl's extended mode "(?x)", a lexical arrangement which allows expressions to be expanded out as little computer programs with comments, is unsupported. It would look awful syntax-coloured in the Inform interface and is not a style of coding to be encouraged.
Inform further does not support the Python extension of named subexpression groups, nor the Java extension of the possessive quantifier "++". There was only so much functionality we could squeeze in.
As verification of Inform's matching algorithm, we took the Perl 5 source code's notorious "re-test.txt" set of 961 test cases, removed the 316 using features unsupported by Inform (220 tested multiline mode, for instance), and ran the remaining 645 cases through Inform. It agrees with Perl on 643 of these: the two outstanding are -
(i) Perl is able to match "^(a\1?){4}$" against "aaaaaa" but Inform is not - Inform's backtracking is not as good when it comes to repetitions of groupings which are recursively defined. (Note that the optional "\1" match refers to the value of the bracketed expression which contains it, so that the interpretation is different on each repetition. Here to match we have to interpret "?" as 0, 0, 1, 0 repeats respectively as we work through the "{4}".)
(ii) Perl matches "((&lt;a-c>)b*?\2)*" against "ababbbcbc" finding the match "ababb", whereas Inform finds the match "ababbbcbc". This is really a difference of opinion about whether the outer asterisk, which is greedy, should be allowed three matches rather than two if to do so requires the inner asterisk, which is not greedy, to eat more than it needs on one of those three matches.
Case (i) is a sacrifice to enable Inform's back-tracking to use less memory. Case (ii) simply seems unimportant.

View file

@ -0,0 +1,25 @@
Example: * About the examples
Location: Preface
RecipeLocation: Preface
Index: About the examples
Description: An explanation of the examples in this documentation, and the asterisks attached to them. Click the heading of the example, or the example number, to reveal the text.
For: Z-Machine
This is the first of about 400 numbered examples. In a few cases, such as this one, they provide a little background information, but almost all demonstrate Inform source text. The techniques demonstrated tend to be included either because they are frequently asked for, or because they show how to achieve some interesting effect.
The same examples are included in <b>both</b> of the books of documentation, but in a different order: in <i>Writing with Inform</i>, they appear near the techniques used to make them work; in <i>The Inform Recipe Book</i>, they are grouped by the effects they provide. For instance, an example called "Do Pass Go", about the throwing of a pair of dice, appears in the "Randomness" section of <i>Writing with Inform</i> and also in the "Dice and Playing Cards" section of <i>The Inform Recipe Book</i>. Clicking the italicised WI and RB buttons at the right-hand side of an example's heading switches between its position in each book.
Many computing books quote excerpts from programs, but readers have grown wary of them: they are tiresome to type in, and may only be fragments, or may not ever have been tested. The authors of Inform have tried to avoid this. All but two dozen examples contain entire source texts. A single click on the paste icon ///paste.png/// (always placed just left of the double-quoted title) will write the complete source text into the Source panel. All that is then required is to click the Go button, and the example should translate into a working game.
In most cases, typing the single command TEST ME will play through a few moves to show off the effect being demonstrated. (You may find it convenient to create a "scratch" project file for temporary trials like this, clearing all its text and starting again with each new test.)
As part of the testing process which verifies a new build of Inform, each example in turn is extracted from this documentation, translated, played through, and the resulting transcript mechanically checked. So the examples may even work as claimed. But the flesh is weak, and there are bound to be glitches. We would welcome reports, so that future editions can be corrected.
Each example is loosely graded by difficulty: if they were exercises in a textbook, the asterisks would indicate how many marks each question scores. As a general rule:
///asterisk.png/// - A simple example, fairly easily guessed.
///asterisk.png/// ///asterisk.png/// - A complicated or surprising example.
///asterisk.png/// ///asterisk.png/// ///asterisk.png/// - An example needing detailed knowledge of many aspects of the system.
///asterisk.png/// ///asterisk.png/// ///asterisk.png/// ///asterisk.png/// - A complete scenario, containing material not necessarily relevant to the topic being demonstrated.
In general, the main text of <i>Writing with Inform</i> tries never to assume knowledge of material which has not yet appeared, but the trickier examples almost always need to break this rule.

View file

@ -0,0 +1,22 @@
Example: * Access All Areas
Location: Changing the behaviour of rules
RecipeLocation: Magic (Breaking the Laws of Physics)
Index: The Pointy Hat of Liminal Transgression
Description: The Pointy Hat of Liminal Transgression allows its wearer to walk clean through closed doors.
For: Z-Machine
If somebody tries to walk through a closed door, the "can't go through closed doors rule" usually stops them. This is a rule belonging to the "check going" rulebook. These names are fairly explanatory when written out, but hard to remember: fortunately we don't need to remember them, as the Index panel contains a full inventory of the check, carry out and report rules for every action, showing all of their names and the order in which they are checked. (We can also find out which rules are stopping an action by typing the testing command ACTIONS.)
Here we make the rule do nothing provided a condition holds:
{*}"Access All Areas"
The extremely difficult door is north of the Standing Room and south of the Room of Walking Upside Down. It is a locked door.
The player is carrying the Pointy Hat of Liminal Transgression. The hat is wearable.
The can't go through closed doors rule does nothing when the Hat is worn.
Test me with "n / wear hat / n".
(The Pointy Hat may be useful in debugging a game, even if it never makes it into the final published work.)

View file

@ -0,0 +1,49 @@
Example: ** Actaeon
Location: Understanding any, understanding rooms
RecipeLocation: Traveling Characters
Index: FOLLOW command
Description: A FOLLOW command allowing the player to pursue a person who has just left the room.
For: Z-Machine
Suppose we want the player to be able to go after characters who are moving around the map. The trick, of course, is that once characters are gone they are no longer visible to "follow [person]", so we need "follow [any person]" to find them.
{*}"Actaeon"
A person has a room called last location.
Understand "follow [any person]" as following. Understand the commands "chase" and "pursue" as "follow".
Following is an action applying to one visible thing.
Check following:
if the noun is the player, say "Wherever you go, there you are." instead;
if the noun is visible, say "[The noun] is right here." instead;
if the last location of the noun is not the location, say "It's not clear where [the noun] has gone." instead.
Here again the best route comes in handy:
{**}Carry out following:
let the destination be the location of the noun;
if the destination is not a room, say "[The noun] isn't anywhere you can follow." instead;
let aim be the best route from the location to the destination;
say "(heading [aim])[line break]";
try going aim.
Corinth is a room. Athens is east of Corinth. Epidaurus is southeast of Corinth and east of Mycenae. Mycenae is south of Corinth. Olympia is west of Mycenae. Argos is south of Mycenae. Thebes is northwest of Athens. Pylos is south of Olympia. Sparta is east of Pylos and south of Argos. Delphi is northwest of Thebes.
Artemis is a woman in Corinth.
We do also have to make sure that whenever we move a person from room to room, we record where they were moved from; otherwise, our clever restrictions about whom the player can pursue will not work properly.
{**}To move (pawn - a person) tidily to (target - a room):
now the last location of the pawn is the holder of the pawn;
move the pawn to the target.
Every turn:
let current location be the location of Artemis;
let next location be a random room which is adjacent to the current location;
if Artemis is visible, say "Artemis heads to [the next location].";
move Artemis tidily to next location;
if Artemis is visible, say "Artemis arrives from [the current location]."
Test me with "wait / follow artemis / follow artemis / follow artemis".

View file

@ -1,11 +1,14 @@
** Stored actions
(Video camera that records all actions; Actor's Studio)
A video camera that records actions performed in its presence, and plays them back with time-stamps.
Example: ** Actor's Studio
Location: Stored actions
RecipeLocation: Cameras and Recording Devices
Index: Video camera that records all actions
Description: A video camera that records actions performed in its presence, and plays them back with time-stamps.
For: Z-Machine
Here we construct a video camera to track and play back actions:
{*}"The Actor's Studio"
Section 1 - The Video Camera
The video camera is a thing carried by the player.
@ -31,11 +34,11 @@ Here we construct a video camera to track and play back actions:
Carry out tuning it to:
now the mode of the noun is the mode understood.
Report tuning it to:
say "You set [the noun] to [mode understood]."
After an actor doing something when the video camera is recording:
After an actor doing something when the video camera is recording:
if the current action is tuning the video camera to recording, make no decision;
if the number of blank rows in the Table of Videotape is greater than zero:
choose a blank row in the Table of Videotape;
@ -56,13 +59,13 @@ Here we construct a video camera to track and play back actions:
blank out the whole row;
if starting playback is false, say "only static.";
otherwise say paragraph break.
Section 2 - The Scenario
The Actor's Studio is a room. Lucas is a man in the Actor's Studio. Persuasion rule: persuasion succeeds.
The Studio contains an edible thing called a croissant.
Test me with "set camera to recording / x lucas / lucas, take inventory / lucas, eat croissant / set camera to playing back / z".
Notice that both Lucas' implied taking action (picking up the croissant) and his eating action are recorded on the same move.
Notice that both Lucas' implied taking action (picking up the croissant) and his eating action are recorded on the same move.

View file

@ -1,6 +1,9 @@
*** New activities
(Radios and other devices active when switched on; Aftershock)
Modifying the rules for examining a device so that all devices have some specific behavior when switched on, which is described at various times.
Example: *** Aftershock
Location: New activities
RecipeLocation: Televisions and Radios
Index: Radios and other devices active when switched on
Description: Modifying the rules for examining a device so that all devices have some specific behavior when switched on, which is described at various times.
For: Z-Machine
The built-in behavior of Inform is to print a line after a device is examined, saying whether the item is on or off. This is often inappropriate, and we could simply turn off that behavior in general by instructing Inform to ignore the "examine devices rule" (see the chapter on rulebooks).
@ -9,60 +12,60 @@ Perhaps, though, we would like continue to have a short passage about the action
{*}"Aftershock"
Section 1 - Showing actions
Showing action of something is an activity.
Rule for showing action of something (called item):
if the item is switched on, say "[The item] is switched on.";
otherwise say "[The item] is switched off."
Borrowing from the rulebooks chapter, we can replace the standard "examine devices" rule with something that uses this activity.
Borrowing from the rulebooks chapter, we can replace the standard "examine devices" rule with something that uses this activity.
{**}The new described devices rule is listed instead of the examine devices rule in the carry out examining rules.
This is the new described devices rule:
if the noun is a device:
if the noun is a device:
carry out the showing action activity with the noun;
now examine text printed is true.
Thus far we have essentially replicated the original behavior, but we've made it possible to write specialized behavior for devices, and to invoke that behavior in other places:
{**}Report switching on something:
{**}Report switching on something:
say "You flip a switch. ";
carry out the showing action activity with the noun instead.
This might be useful for an electric lamp kind:
{**}Section 2 - Electric Lamps
An electric lamp is a kind of device.
An electric lamp is a kind of device.
Rule for showing action of an electric lamp (called item):
if the item is switched on, say "[The item] is lit[if the number of visible lit things is greater than 1], competing with [the list of visible lit things which are not the item][end if].";
otherwise say "[The item] is dark."
Carry out switching on an electric lamp: now the noun is lit. Carry out switching off an electric lamp: now the noun is unlit.
{**}Section 2 - The Scenario
The time of day is 3:47 AM. When play begins, now the right hand status line is "[time of day]".
The Downstairs Hallway is a dark room. "The only room in the house with no furniture and almost nothing on the walls. At times like this you always notice the crack in the plaster, originating near the light fixture and running almost all the way to the wall."
A plastic jug of filtered water is in the Downstairs Hallway. The description is "Five gallons, not that that will last you very long, hot as it has been lately."
The Downstairs Hallway is a dark room. "The only room in the house with no furniture and almost nothing on the walls. At times like this you always notice the crack in the plaster, originating near the light fixture and running almost all the way to the wall."
A plastic jug of filtered water is in the Downstairs Hallway. The description is "Five gallons, not that that will last you very long, hot as it has been lately."
The crack is scenery in the Hallway. The description is "No, the ceiling isn't going to fall on you today."
The light fixture is an electric lamp in the Hallway. It is switched on, lit, and scenery. The description is "A plain globe of frosted glass containing the light bulb. Nothing special, and you never think about it except when, as now, you are forced to spend hours in this room."
The flashlight is an electric lamp carried by the player. The description is "A shiny red flashlight." The portable radio is a device carried by the player. The description is "A small battery-operated radio which you received for free with your subscription to US News & World Report. It has served you well through many earthquakes past."
And with our activity, we can override the flashlight's electric lamp behavior with new behavior:
{**}Rule for showing action of the flashlight:
if the flashlight is switched on, say "A strong, narrow beam of light shines from the flashlight.";
otherwise say "It is currently switched off."
...or give special actions for the radio:
{**}Rule for showing action of the radio:
@ -71,5 +74,5 @@ And with our activity, we can override the flashlight's electric lamp behavior w
Instead of listening in the presence of the switched on radio:
carry out the showing action activity with the radio instead.
Test me with "examine light / switch light off / switch flashlight on / switch radio on / examine radio / examine flashlight".

View file

@ -0,0 +1,28 @@
Example: * Age of Steam
Location: Using the Scene index
RecipeLocation: Scene Changes
Index: Scene which starts and finishes
Description: The railway-station examples so far put together into a short game called "Age of Steam".
For: Z-Machine
The following source is very short and simple, yet it already feels surprisingly interesting in play, because something is going on which the player does not control but must observe. The single scene both starts and finishes.
{*}"Age of Steam"
The Station is a room. "Eynforme Halt is a raised platform fringed with cowslip: a whistle-stop with no more than a signal and a water-tank."
The Flying Scotsman is fixed in place. "The Flying Scotsman, fastest train in the world, is now at a dead standstill."
Train Stop is a scene. Train Stop begins when the player is in the Station for the third turn. Train Stop ends when the time since Train Stop began is 3 minutes.
When Train Stop begins:
now the Flying Scotsman is in the Station;
say "The Flying Scotsman pulls up at the platform, to a billow of steam and hammering."
When Train Stop ends:
now the Flying Scotsman is nowhere;
say "The Flying Scotsman inches away, with a squeal of released brakes, gathering speed invincibly until it disappears around the hill. All is abruptly still once more."
Instead of entering the Flying Scotsman, say "Alas, the [time when Train Stop began] arrival is only to take on water, not to set down or pick up."
Test me with "z / z / z / enter flying scotsman / z / z".

View file

@ -1,8 +1,11 @@
* Pattern matching
(Phrase to repeat a rule--Phrase to let us say things some number of times; Ahem)
Writing a phrase, with several variant forms, whose function is to follow a rule several times.
Example: * Ahem
Location: Pattern matching
RecipeLocation: Varying What Is Written
Index: Phrase to repeat a rule
Description: Writing a phrase, with several variant forms, whose function is to follow a rule several times.
For: Z-Machine
As we see in the example here, it is possible to use slashed variations in more than one place in a phrase, and to offer a number of separate forms. The main rule of thumb to remember is that value inputs for the phrase should always be separated by some text; so
As we see in the example here, it is possible to use slashed variations in more than one place in a phrase, and to offer a number of separate forms. The main rule of thumb to remember is that value inputs for the phrase should always be separated by some text; so
To do/follow (chosen rule - a rule) exactly/precisely/just/-- (N - a number) time/times:
....
@ -14,23 +17,23 @@ would cause a problem when we tried to call it with
In general, we probably don't need to make our phrase definitions quite so flexible as this, but it's a good idea to account for "a" vs. "the", and for the possibility of using singular and plural forms, especially when writing extensions or other source to be shared.
{*} "Ahem"
To do/follow (chosen rule - a rule) exactly/precisely/just (N - a number) time/times:
repeat with index running from 1 to N:
follow chosen rule.
This is the throat-clearing rule:
say "'Ahem,' says [a random visible person who is not the player]."
After waiting:
do the throat-clearing rule just one time.
Instead of listening:
follow the throat-clearing rule precisely three times.
Instead of smelling:
follow the throat-clearing rule exactly 2 times.
Chateau Marmont is a room. Tom, Jack, Zsa-Zsa, and Wilma-Faye are people in the Chateau. Zsa-Zsa and Wilma-Faye are women.
Test me with "wait / smell / listen".
Chateau Marmont is a room. Tom, Jack, Zsa-Zsa, and Wilma-Faye are people in the Chateau. Zsa-Zsa and Wilma-Faye are women.
Test me with "wait / smell / listen".

View file

@ -0,0 +1,154 @@
Example: **** Air Conditioning is Standard
Location: Writing a paragraph about
RecipeLocation: Event Scheduling
Index: Paragraphs of flexible descriptions
Description: Uses "writing a paragraph about" to make person and object descriptions that vary considerably depending on what else is going on in the room, including some randomized NPC interactions with objects or with each other.
For: Z-Machine
{*}"Air Conditioning is Standard"
Section 1 - The Garage
A person has some text called current occupation. The current occupation of a person is usually "None".
Mood is a kind of value. The moods are bemused, bored, attentive, rapt, and blushing. A person has a mood. A person is usually attentive.
Instead of examining a person:
now every thing is unmentioned;
carry out the writing a paragraph about activity with the noun.
Rule for writing a paragraph about a person (called X):
let the subsequent mention be "Name";
if the current occupation of X is not "None":
say "[current occupation of X]. ";
let the subsequent mention be "He";
if X is female, let the subsequent mention be "She";
if X wears something unmentioned:
if the subsequent mention is "Name", say "[The X] ";
otherwise say "[subsequent mention] ";
say "is wearing [a list of unmentioned things worn by X]";
if X carries something unmentioned, say " and carrying [a list of unmentioned things carried by X]";
say ".";
otherwise:
if X carries something unmentioned:
if the subsequent mention is "Name", say "[The X] ";
otherwise say "[subsequent mention] ";
say " is carrying [a list of unmentioned things carried by X]."
The Garage is a room. "Above the street door is a spectacular art nouveau fanlight, wherein a stained-glass Spirit of Progress bestows the gift of Transportation on mankind.
The sun, gleaming through the hair of Progress, throws amber curls on the macadam floor."
The fanlight is scenery in the Garage. The description is "A semi-circle of stained glass as wide as the garage door, designed by Louis Comfort Tiffany himself. No expense has been spared."
The gift of Transportation is part of the fanlight. The description is "The gift of Transportation is envisioned as a cornucopia disgorging a steam locomotive. And that blue bit of glass might be the Montgolfier balloon."
The Spirit of Progress is part of the fanlight. The description is "It is part of her character to have bare shoulders like that."
The machinist is a bored man. He is in the Garage. He is wearing a grimy pair of overalls. He carries a wrench and a screwdriver. The current occupation of the machinist is "[The machinist] is making some adjustments to [the random thing which is part of the Victorian Car] with his [random thing carried by the machinist]"
The Victorian Car is a device in the Garage. A cast-iron steering wheel, a leather bucket seat, a horn, and a combustion engine are part of the Victorian Car. The seat is an enterable supporter.
Rule for writing a paragraph about a device (called X):
let the subsequent mention be "Name";
if the X is unmentioned:
say "[The X] is here. ";
let the subsequent mention be "It";
if something is part of X:
if the subsequent mention is "Name", say "[The X] ";
otherwise say "[subsequent mention] ";
say "[if a mentioned thing is part of X]also [end if]features[if a mentioned thing is part of X], in addition to [the list of mentioned things which are part of X],[end if] [a list of unmentioned things which are part of X]";
say ".".
Rule for printing the name of the steering wheel while writing a paragraph about a person:
say "steering wheel".
A supporter has some text called position. The position of a supporter is usually "None".
The Office is west of the Garage. The Office contains a desk. The desk has the position "A [desk] with several dozen drawers stands in the center of the room". On the desk are some papers.
After printing the name of a supporter (called X) which supports an unmentioned thing:
now X is unmentioned.
Rule for writing a paragraph about a supporter (called X):
let the subsequent mention be "Name";
if the position of X is not "None":
say "[position of X]. ";
let the subsequent mention be "It";
if a mentioned thing is on X:
say "Besides [the list of mentioned things which are on X], ";
let the subsequent mention be "it";
if the subsequent mention is "Name", say "[The X] ";
otherwise say "[subsequent mention] ";
say "holds [a list of unmentioned things which are on X]."
Section 2 - Schedule
The time of day is 4:38 PM.
At 4:42 PM:
move the machinist to the Office;
say "The machinist wanders into the Office to get some paperwork.";
now every thing carried by the machinist is on the desk;
now the current occupation of the machinist is "[The machinist] rifles through [the papers] on [the desk]".
At 4:43 PM:
move the young lady to the Garage;
if the young lady can be seen by the player,
say "An attractive young lady walks in from the street, and glances around as though she has never been here before."
At 4:45 PM:
if the young lady can be seen by the player,
say "With a not-quite-convincing air of innocence, [the young lady] happens to lean upon [the horn], which bleats loudly.";
otherwise say "There is a honk from the Garage[if the machinist can be seen by the player]. The machinist looks up with a frown[end if].";
now the horn is mentioned.
At 4:46 PM:
move the machinist to the Garage;
say "The machinist strolls from the Office into the Garage to find out what is going on.";
now the current occupation of the machinist is "[The machinist] is chatting with [the young lady]. He seems to be demonstrating the various features of [the car], including [the random thing which is part of the car]";
now the current occupation of the young lady is "[The young lady] is asking [the machinist] a number of questions about [the car]".
At 4:49 PM:
if the young lady can be seen by the player, say "[The machinist] gives [the young lady] his arm to climb into [the seat].";
move the young lady to the seat;
now the young lady is rapt;
now the current occupation of the young lady is "[The young lady] is turning [the steering wheel] from side to side";
now the current occupation of the machinist is "[The machinist] is leaning on the door of [the car], pointing out features to [the young lady]";
move the besotted expression to the machinist;
now the machinist is wearing the besotted expression.
At 4:52 PM:
now the sober grey gown is unbuttoned at the neck;
if the young lady can be seen by the player, say "[The young lady] murmurs something about the wilting heat, and undoes a button or two of her gown. The machinist's expression is comical, or would be, if you weren't annoyed."
Every turn when the player is in the Garage and young lady is on the seat:
say "You are beginning to feel a little unnecessary in this scene."
Every turn when the player is in the Office and the young lady is on the seat:
say "There's no sound at all from the other room, not even conversation."
Before going to the Garage when the young lady is on the seat:
now the sober grey gown is tellingly dishevelled;
move the young lady to the Garage;
now the young lady is blushing;
say "There is a flurry of movement as you enter the room.";
now the current occupation of the young lady is "[The young lady] stands near the door, tapping her foot nervously";
now the besotted expression is nowhere;
now the current occupation of the machinist is "[The machinist] is leaning against [the car], looking smug".
Section 3 - Initially Out of Play
The besotted expression is a wearable thing. The description is "It looks foolish, doesn't it?"
The young lady is a bemused woman. She is wearing a sober grey gown and a pair of black boots. The current occupation of the young lady is "[The young lady] is running a gloved finger along the chassis of [the victorian car]"
Before printing the name of the young lady while writing a paragraph about a person:
say "[mood of the young lady] "
The description of the grey gown is "Something about the perfect row of tiny buttons has the wrong effect -- at any rate, it is natural to wonder how long they take to undo." The gown can be buttoned almost to the chin, unbuttoned at the neck, or tellingly dishevelled.
Rule for printing the name of the gown when writing a paragraph about a person:
say "sober grey gown ([sober grey gown condition])"
Test me with "z / look / look / z / look / west / east / z / look / z / look / z / look / west / east".

View file

@ -1,11 +1,14 @@
*** Numbers and real numbers
(Telephones with standard American-length phone numbers; Alias)
A telephone with phone numbers of the standard American seven-digit length.
Example: *** Alias
Location: Numbers and real numbers
RecipeLocation: Telephones
Index: Telephones with standard American-length phone numbers
Description: A telephone with phone numbers of the standard American seven-digit length.
For: Glulx
Seven-digit telephone numbers are too long for Inform to handle when compiling to the Z-Machine, but they will work under Glulx. To have this example succeed, make sure that you have selected the Glulx option in your settings menu.
{*}"Alias"
A telephone is a kind of thing. Understand "phone" or "telephone" as a telephone.
A phone number is a kind of value. 999-9999 specifies a phone number.
@ -22,14 +25,14 @@ Now we borrow some techniques from the Understanding chapter to set up dialing a
Report dialing it on:
say "You dial [the phone number understood]."
This much is enough to let us dial telephone numbers and have Inform report that we've done so; it doesn't actually provide a telephone system such that we could reach and converse with other characters (but see the other telephone examples in the recipe book for more on how one might do that).
We'll set up a little political espionage scenario from which our player can make calls:
{**}The Senator's Junior Suite is a room. "The Senator appears, unfortunately, to have very precise habits: little in the room has been moved from its usual place; the trash can is empty; the bed has been remade[if the blue paper is unexamined]. There may in fact be nothing to find here[end if]."
The bed is an enterable scenery supporter in the Junior Suite.
The bed is an enterable scenery supporter in the Junior Suite.
The player is wearing a housekeeping uniform and a brunette wig. The player carries a telephone called a Nokia.
@ -41,9 +44,9 @@ And what if we'd like to have the player learn some phone numbers during the gam
{**}A thing can be examined or unexamined. Carry out examining something: now the noun is examined.
Understand "Stephen" as 555-2513 when the blue paper is examined.
Understand "Stephen" as 555-2513 when the blue paper is examined.
This will understand CALL STEPHEN once the paper is examined; before that, the player will just get the "That's not a number you know" response that Inform uses for all attempts to call unknown names.
This will understand CALL STEPHEN once the paper is examined; before that, the player will just get the "That's not a number you know" response that Inform uses for all attempts to call unknown names.
We'd better plant this paper for the player to find:
@ -51,4 +54,4 @@ We'd better plant this paper for the player to find:
The drawer is part of the dresser. It is closed and openable. The dresser is in The Senator's Junior Suite. The lamp is on the dresser. The description of the dresser is "The single drawer is [if the drawer is open]open[otherwise]shut[end if]."
Test me with "dial 555-9999 / call home on the telephone / phone the president / call stephen / open drawer / read paper / call stephen / put phone in drawer / close drawer / call stephen".
Test me with "dial 555-9999 / call home on the telephone / phone the president / call stephen / open drawer / read paper / call stephen / put phone in drawer / close drawer / call stephen".

View file

@ -1,37 +0,0 @@
* Writing and reading tables to external files
(Preferences file loaded on replaying; Alien Invasion Part 23)
Keeping a preference file that could be loaded by any game in a series.
Suppose that we have a series of games each of which allows the player to select a puzzle difficulty level. When the player plays a new game in the series, we want them to start out by default with the same difficulty level they faced earlier on, so we store this information in a small preferences file, as follows:
{*}"Alien Invasion Part 23"
A difficulty is a kind of value. The difficulties are easy, moderate, hard, and fiendish.
Understand "use [difficulty] puzzles" as selecting difficulty. Selecting difficulty is an action out of world, applying to one difficulty.
Carry out selecting difficulty:
choose row 1 in the Table of Preference Settings;
now challenge level entry is difficulty understood;
say "Puzzles will be [challenge level entry] from now on."
The File of Preferences is called "prefs".
When play begins:
if File of Preferences exists:
read File of Preferences into the Table of Preference Settings;
choose row 1 in the Table of Preference Settings;
say "(The current puzzle difficulty is set to [challenge level entry].)"
Check quitting the game:
write File of Preferences from the Table of Preference Settings.
Table of Preference Settings
challenge level
easy
The Sewer Junction is a room.
Our preference file is restricted to a single option here for simplicity's sake, but we could keep track of more information -- whether the player preferred verbose or brief room descriptions, screen configurations, and so on.
If we were disposed to be somewhat crueler, we could use a similar method to make the player finish each episode of the series in order to "unlock" the next. All we would need to do is store a numerical password in our preferences file when the player finished a given level; the next level would check, say, the Table of Completed Levels for that password, and refuse to play unless the right number were present.

View file

@ -0,0 +1,40 @@
Example: * Alien Invasion Part 23
Location: Writing and reading tables to external files
RecipeLocation: Start-Up Features
Index: Preferences file loaded on replaying
Description: Keeping a preference file that could be loaded by any game in a series.
For: Glulx
Suppose that we have a series of games each of which allows the player to select a puzzle difficulty level. When the player plays a new game in the series, we want them to start out by default with the same difficulty level they faced earlier on, so we store this information in a small preferences file, as follows:
{*}"Alien Invasion Part 23"
A difficulty is a kind of value. The difficulties are easy, moderate, hard, and fiendish.
Understand "use [difficulty] puzzles" as selecting difficulty. Selecting difficulty is an action out of world, applying to one difficulty.
Carry out selecting difficulty:
choose row 1 in the Table of Preference Settings;
now challenge level entry is difficulty understood;
say "Puzzles will be [challenge level entry] from now on."
The File of Preferences is called "prefs".
When play begins:
if File of Preferences exists:
read File of Preferences into the Table of Preference Settings;
choose row 1 in the Table of Preference Settings;
say "(The current puzzle difficulty is set to [challenge level entry].)"
Check quitting the game:
write File of Preferences from the Table of Preference Settings.
Table of Preference Settings
challenge level
easy
The Sewer Junction is a room.
Our preference file is restricted to a single option here for simplicity's sake, but we could keep track of more information -- whether the player preferred verbose or brief room descriptions, screen configurations, and so on.
If we were disposed to be somewhat crueler, we could use a similar method to make the player finish each episode of the series in order to "unlock" the next. All we would need to do is store a numerical password in our preferences file when the player finished a given level; the next level would check, say, the Table of Completed Levels for that password, and refuse to play unless the right number were present.

View file

@ -0,0 +1,27 @@
Example: * All Roads Lead to Mars
Location: Adjacent rooms and routes through the map
RecipeLocation: Map
Index: Rooms player is forced to visit in order
Description: Layout where the player is allowed to wander any direction he likes, and the map will arrange itself in order so that he finds the correct "next" location.
For: Z-Machine
Suppose we want to allow the player to wander freely in any direction, but ourselves maintain control over the order in which they encounter the rooms. This sort of effect emphasizes the order of the story-telling over any kind of rigorous simulation of space; on multiple play-throughs, the player might not find all the same rooms in the same locations.
{*}"All Roads Lead to Mars"
Before going a direction (called way) when a room (called next location) is not visited:
let further place be the room the way from the location;
if further place is a room, continue the action;
change the way exit of the location to the next location;
let reverse be the opposite of the way;
change the reverse exit of the next location to the location.
The Open Plain is a room. "A wide-open grassy expanse, from which you could really go any way at all."
The Hilly Place is a room. "The grassland gives way to a somewhat more hilly area, though there is still very little to guide you any particular way."
The Stream is a room. "This is the third place you've been today, and so the stream is welcome. How refreshing!"
Test me with "n / s / e / e".
If we wanted still to be able to find routes between places, we could define a relationship of connection between rooms, which we would add to as we went along.

View file

@ -1,23 +0,0 @@
* Defining new assertion verbs
(Shifting alliances among people; Unthinkable Alliances)
People are to be grouped into alliances. To kiss someone is to join their faction, which may make a grand alliance; to strike them is to give notice of quitting, and to become a lone wolf.
The following is best tested by experimentally kissing and/or attacking, and typing RELATIONS after every change to see the effect.
{*}"Unthinkable Alliances"
Unthinkable Solutions is a room. Sophie, Daisy, Ryan and Owen are in Unthinkable Solutions.
Alliance relates people to each other in groups. The verb to help means the alliance relation.
Sophie helps Ryan. Daisy helps Ryan. Owen helps the player.
Instead of kissing someone (called the blessed one):
say "Smack!";
now the player helps the blessed one.
Instead of attacking someone (called the vilified one):
say "Smack!";
now the player does not help the vilified one.
Test me with "relations / kiss sophie / relations / hit ryan / relations".

View file

@ -1,50 +0,0 @@
* New commands for old grammar
(USE action which divines rational behavior for a wide range of possible nouns; Alpaca Farm)
A generic USE action which behaves sensibly with a range of different objects.
This example takes the ordering of grammar lines to its logical extreme, sorting the player's input into different categories depending on the kind and condition of the objects mentioned.
{*}"Alpaca Farm"
Understand "use [an edible thing]" as eating.
Understand "use [a wearable thing]" as wearing.
Understand "use [a closed openable container]" as opening. Understand "use [an open openable container]" as closing.
Understand "use [something preferably held] on [a locked lockable thing]" as unlocking it with (with nouns reversed). Understand "use [something preferably held] on [an unlocked lockable thing]" as locking it with (with nouns reversed).
Understand "use [a switched off device]" as switching on.
Understand "use [something]" as using. Using is an action applying to one thing. Carry out using: say "You will have to be more specific about your intentions."
Understand "use [a door]" as opening. Understand "use [an open door]" as entering.
The Llama Pen is a room. North of the Pen is the gate. The gate is a door. North of the gate is the Rocky Path. The brown llama is an animal in the Llama Pen.
Appearance is a kind of value. The appearances are muddy, scruffy, fluffy, and dapper. The brown llama has an appearance. The brown llama is muddy. Before printing the name of the brown llama, say "[appearance] ". Before printing the name of the brown llama while grooming: say "now-[if appearance of the brown llama is less than dapper]merely-[end if]".
A grooming tool is a kind of thing. Understand "use [a grooming tool] on [something]" as grooming it with (with nouns reversed). Grooming it with is an action applying to two things. Understand "groom [something] with [something]" as grooming it with.
Carry out grooming it with:
if the appearance of the noun is less than dapper, now the appearance of the noun is the appearance after the appearance of the noun.
Report grooming it with:
say "You attend diligently to the appearance and hygiene of [the noun]."
Instead of using a grooming tool in the presence of the brown llama:
try grooming the brown llama with the noun.
The player carries some nail nippers, a slicker brush, and an apple. The apple is edible. The brush and the nippers are grooming tools. The player wears a sombrero.
The description of the nail nippers is "Ten inches long, to give you the necessary leverage to cut tough llama toenails. It still helps to soften them up by making the llama stand in a bucket of water first, though."
The description of the slicker brush is "Fine, angled soft bristles set into a broad back, perfect for removing mud from the coat of a long-woolled llama."
The industrial-strength blower is a fixed in place device in the Llama Pen. "Attached to the nearest wall, on its own movable boom, is an industrial-strength blower for doing llama hair."
Understand "use [switched off blower]" as switching on. Understand "use [switched on blower] on [brown llama]" as grooming it with (with nouns reversed). Instead of using the blower in the presence of the brown llama, try grooming the brown llama with the blower.
Test me with "use gate / use blower / use nippers / use brush / use apple / remove sombrero / use sombrero".
Whether we actually want a USE action is a subject of some theoretical debate in the IF community. On the one hand, it helps avoid guess-the-verb problems where the player cannot figure out what term to use in order to express a fairly simple idea. On the other, it encourages the player to think that all items have one and exactly one use, rather than getting them to consider the range of possibilities that arise from having a complex vocabulary.

View file

@ -0,0 +1,53 @@
Example: * Alpaca Farm
Location: New commands for old grammar
RecipeLocation: Clarification and Correction
Index: USE action which divines rational behavior for a wide range of possible nouns
Description: A generic USE action which behaves sensibly with a range of different objects.
For: Z-Machine
This example takes the ordering of grammar lines to its logical extreme, sorting the player's input into different categories depending on the kind and condition of the objects mentioned.
{*}"Alpaca Farm"
Understand "use [an edible thing]" as eating.
Understand "use [a wearable thing]" as wearing.
Understand "use [a closed openable container]" as opening. Understand "use [an open openable container]" as closing.
Understand "use [something preferably held] on [a locked lockable thing]" as unlocking it with (with nouns reversed). Understand "use [something preferably held] on [an unlocked lockable thing]" as locking it with (with nouns reversed).
Understand "use [a switched off device]" as switching on.
Understand "use [something]" as using. Using is an action applying to one thing. Carry out using: say "You will have to be more specific about your intentions."
Understand "use [a door]" as opening. Understand "use [an open door]" as entering.
The Llama Pen is a room. North of the Pen is the gate. The gate is a door. North of the gate is the Rocky Path. The brown llama is an animal in the Llama Pen.
Appearance is a kind of value. The appearances are muddy, scruffy, fluffy, and dapper. The brown llama has an appearance. The brown llama is muddy. Before printing the name of the brown llama, say "[appearance] ". Before printing the name of the brown llama while grooming: say "now-[if appearance of the brown llama is less than dapper]merely-[end if]".
A grooming tool is a kind of thing. Understand "use [a grooming tool] on [something]" as grooming it with (with nouns reversed). Grooming it with is an action applying to two things. Understand "groom [something] with [something]" as grooming it with.
Carry out grooming it with:
if the appearance of the noun is less than dapper, now the appearance of the noun is the appearance after the appearance of the noun.
Report grooming it with:
say "You attend diligently to the appearance and hygiene of [the noun]."
Instead of using a grooming tool in the presence of the brown llama:
try grooming the brown llama with the noun.
The player carries some nail nippers, a slicker brush, and an apple. The apple is edible. The brush and the nippers are grooming tools. The player wears a sombrero.
The description of the nail nippers is "Ten inches long, to give you the necessary leverage to cut tough llama toenails. It still helps to soften them up by making the llama stand in a bucket of water first, though."
The description of the slicker brush is "Fine, angled soft bristles set into a broad back, perfect for removing mud from the coat of a long-woolled llama."
The industrial-strength blower is a fixed in place device in the Llama Pen. "Attached to the nearest wall, on its own movable boom, is an industrial-strength blower for doing llama hair."
Understand "use [switched off blower]" as switching on. Understand "use [switched on blower] on [brown llama]" as grooming it with (with nouns reversed). Instead of using the blower in the presence of the brown llama, try grooming the brown llama with the blower.
Test me with "use gate / use blower / use nippers / use brush / use apple / remove sombrero / use sombrero".
Whether we actually want a USE action is a subject of some theoretical debate in the IF community. On the one hand, it helps avoid guess-the-verb problems where the player cannot figure out what term to use in order to express a fairly simple idea. On the other, it encourages the player to think that all items have one and exactly one use, rather than getting them to consider the range of possibilities that arise from having a complex vocabulary.

View file

@ -1,11 +1,14 @@
* Regular expression matching
(Testing command; Alpha)
Creating a beta-testing command that matches any line starting with punctuation.
Example: * Alpha
Location: Regular expression matching
RecipeLocation: Testing
Index: Testing command
Description: Creating a beta-testing command that matches any line starting with punctuation.
For: Z-Machine
Sometimes we want to let testers of a game insert their own comments during a transcript, without those comments wasting turns of the game or producing lengthy or inappropriate parser errors. Many testers have a habit of prefacing comments with a punctuation mark, so let's say that we'd like to catch any command that starts with any punctuation at all:
{*} "Alpha"
When play begins:
say "Hi, Larry! Thanks for testing my game!!"
@ -17,5 +20,5 @@ Sometimes we want to let testers of a game insert their own comments during a tr
if the player's command matches the regular expression "^\p":
say "(Noted.)";
reject the player's command.
Test me with "x me / x troll / !this game is a bit dull so far / kiss troll / ? does this troll do anything? / :yawn".
Test me with "x me / x troll / !this game is a bit dull so far / kiss troll / ? does this troll do anything? / :yawn".

View file

@ -1,33 +0,0 @@
** Amusing a victorious player
(AMUSING menu shown at the endgame; Xerxes)
Offering the player a menu of things to read after winning the game.
Building a menu is moderately tedious, so we will rely on the standard menu extensions provided. Thus:
{*}"Xerxes"
Include Basic Screen Effects by Emily Short. Include Menus by Emily Short.
Table of Amusing Matter
title subtable description toggle
"Cult Revisions" -- "Did you try... [paragraph break] banning the worship of Seth? [line break] of Dionysus? [line break] assigning all your priests to Re? [line break] assigning male priests to Cybele? [line break] assigning married priestesses to Hestia? [line break] identifying one god as another (e.g., Isis and Hecate)? [line break] identifying a mortal as a god (e.g., Alexander as Helios-Apollo)?" --
"Military Revisions" -- "Did you try... [paragraph break] allying a Greek city-state with the Persians? (try >MEDIZE) [line break] playing Athens as a land-based power?" --
Rule for amusing a victorious player:
now the current menu is the Table of Amusing Matter;
now the current menu title is "Things to Try";
carry out the displaying activity;
clear the screen.
Omitting about a half million words from this rigorous and educational but nonetheless enthralling simulation of centuries of history, culture, and religion, we will skip directly to:
{**}Athens is a room.
Use scoring.
Every turn:
if the score is greater than 10000, end the story finally.
When play begins: now the score is 10001.
Test me with "z".

View file

@ -0,0 +1,21 @@
Example: * Anchorite
Location: New commands for old grammar
RecipeLocation: Entering and Exiting, Sitting and Standing
Index: GET DOWN and DOWN understood as EXIT
Description: By default, Inform understands GET OFF, GET UP, or GET OUT when the player is sitting or standing on an enterable object. We might also want to add GET DOWN and DOWN as exit commands, though.
For: Z-Machine
With GET DOWN, we can replace the whole command, which will not interfere with the normal function of the TAKE verb, or allow the player to attempt to GET any other directions:
{*}"Anchorite"
The Solitary Place is a room. "A glittering, shimmering desert without either locusts or honey." The pillar is an enterable supporter in the Solitary Place. "The broken pillar is short enough to climb and sit on." The description of the pillar is "Once it was a monument: a long frieze of battles and lion-hunts spirals up the side, in honor of an earthly king." The player is on the pillar.
Understand "get down" as exiting.
This doesn't cover the case where the player just types "DOWN", and we don't want to preempt the normal operation of the GO action here. So instead of writing a new understand instruction, we might catch this one at the action-processing level:
{**}Instead of going down when the player is on a supporter:
try exiting.
Test me with "down / enter pillar / get down / down / get down".

View file

@ -1,19 +1,22 @@
* How many turns?
(Child who asks if we're there yet; Annoyotron Jr)
A child who after a certain period in the car starts asking annoying questions.
Example: * Annoyotron Jr
Location: How many turns?
RecipeLocation: Liveliness
Index: Child who asks if we're there yet
Description: A child who after a certain period in the car starts asking annoying questions.
For: Z-Machine
{*}"Annoyotron Jr"
The Minivan is a room. The Open Road is outside from the Minivan. Pete is a man in the Minivan. "Pete [if the player has been in the Minivan for 3 turns]is starting to look bored[otherwise]is playing with his travel activity book[end if]."
Every turn:
if the player has been in the Minivan for 5 turns, say "'Are we there [if saying no]now?'[otherwise]yet?' asks Pete.[end if]"
Instead of saying no:
say "'Oh,' says Pete. There is a blessed, momentary silence."
Instead of going to the Open Road:
say "You leap to your death.";
end the story.
Test me with "z / z / look / g / g / g / no / z / z / z / no / z / out".
Test me with "z / z / look / g / g / g / no / z / z / z / no / z / out".

View file

@ -1,32 +1,35 @@
* What are activities?
(Varying room description text; Ant-Sensitive Sunglasses)
What are activities good for? Controlling output when we want the same action to be able to produce very flexible text depending on the state of the world -- in this case, making highly variable room description and object description text.
Example: * Ant-Sensitive Sunglasses
Location: What are activities?
RecipeLocation: Room Descriptions
Index: Varying room description text
Description: What are activities good for? Controlling output when we want the same action to be able to produce very flexible text depending on the state of the world -- in this case, making highly variable room description and object description text.
For: Z-Machine
Suppose we want to create an object -- or maybe even a series of objects -- that warp the player's perception of every room description and object around them.
Suppose we want to create an object -- or maybe even a series of objects -- that warp the player's perception of every room description and object around them.
We've already seen some ways to create variations in text. For instance, we could make a room description with if substitutions in it, like so:
The Kitchen is a room. "[if the player is wearing the sunglasses]Are ants coming out of the sink? No, probably no.[otherwise]A small kitchen tucked into a corner of the vacation house. There is storage space for five or six cups, a sink, a two-ring stove; nothing else to speak of.[end if]"
That works fine if we have one or two variations we want to add; it's not so good if we're going to have several items that work like the sunglasses, or if we want the sunglasses to override the description of every room in the house.
A slightly more flexible method is to use a substitution that calls out to a say phrase, like this:
The Kitchen is a room. "[kitchen-description]"
To say kitchen-description:
if the player is wearing the sunglasses:
say "Are ants coming out of the sink? No, probably no.";
otherwise:
say "A small kitchen tucked into a corner of the vacation house. There is storage space for five or six cups, a sink, a two-ring stove; nothing else to speak of."
But again this doesn't handle the case of overriding multiple rooms at once very well.
When we reach a point where we need a given piece of text to be very flexible depending on the world model, it's time to use an activity.
Activities offer several advantages. One, we can create an activity like this:
Printing the room-description of something is an activity.
Printing the room-description of something is an activity.
and then write a rule that applies to multiple rooms at once, like:
@ -37,17 +40,17 @@ Inform's usual rule-ranking also means that more-specific rules will override le
Rule for printing the room-description of the Kitchen when the player wears the sunglasses:
say "Are ants coming out of the sink? No, probably not."
and have that rule override the behavior of the activity just in the kitchen. Meanwhile, our base room descriptions remain straightforward and uncluttered by if-statements.
Several other examples will show how to hook activities into existing actions: Crusoe goes into detail about how how to make the descriptions of things more variable, and Aftershock demonstrates activities for describing the behavior of switchable devices.
Several other examples will show how to hook activities into existing actions: Crusoe goes into detail about how how to make the descriptions of things more variable, and Aftershock demonstrates activities for describing the behavior of switchable devices.
Here, we preview all of those methods, just to get a sense of how they work and why they might be useful in controlling a game. Subsequent chapters go into more detail about the syntax of creating activities and the list of activities that are already defined by Inform.
{*} "Ant-Sensitive Sunglasses"
Part 1 - Procedure
To add a new activity to an existing Inform rule, we need to do three things:
1) Define our new activity.
@ -55,7 +58,7 @@ To add a new activity to an existing Inform rule, we need to do three things:
3) Replace the existing rule in Inform's rulebooks with a new one that calls on our activity.
Here we do this with examining:
{**}Section 1 - Item Description
Printing the description of something is an activity.
@ -70,7 +73,7 @@ Now, by default, we want to print the description property; we just want the opt
Next, we need the standard examining rule to look at our printing-the-description activity:
{**}The activity-based examining rule is listed instead of the standard examining rule in the carry out examining rules.
{**}The activity-based examining rule is listed instead of the standard examining rule in the carry out examining rules.
This is the activity-based examining rule:
carry out the printing the description activity with the noun;
@ -80,7 +83,7 @@ Now we do the same thing to room descriptions.
{**}Section 2 - Room Description
Printing the room-description of something is an activity.
Printing the room-description of something is an activity.
Rule for printing the room-description of a room (called item):
if the description of the item is not "":
@ -88,13 +91,13 @@ Now we do the same thing to room descriptions.
otherwise:
do nothing instead.
The activity-based room description body text rule is listed instead of the room description body text rule in the carry out looking rules.
Our replacement rule this time around is a little bit trickier just because the rule that we're replacing is a complicated one: describing a room already checks to see whether there's light to see by, whether the player has turned off room descriptions when entering a room for the second time, and whether the player character is (say) inside a closed box they can't see out of.
The activity-based room description body text rule is listed instead of the room description body text rule in the carry out looking rules.
Our replacement rule this time around is a little bit trickier just because the rule that we're replacing is a complicated one: describing a room already checks to see whether there's light to see by, whether the player has turned off room descriptions when entering a room for the second time, and whether the player character is (say) inside a closed box they can't see out of.
But all of those details are re-copied from the standard rules, and the important thing is that, at the end, we again carry out our activity.
{**}This is the activity-based room description body text rule:
{**}This is the activity-based room description body text rule:
if the visibility level count is 0:
if set to abbreviated room descriptions, continue the action;
if set to sometimes abbreviated room descriptions and
@ -108,9 +111,9 @@ But all of those details are re-copied from the standard rules, and the importan
otherwise if the visibility ceiling is the location:
if set to abbreviated room descriptions, continue the action;
if set to sometimes abbreviated room descriptions and abbreviated form
allowed is true and the location is visited, continue the action;
allowed is true and the location is visited, continue the action;
carry out the printing the room-description activity with the location.
Section 3 - Device Description
Showing action of something is an activity.
@ -124,8 +127,8 @@ But all of those details are re-copied from the standard rules, and the importan
This is the activity-based described devices rule:
if the noun is a device:
carry out the showing action activity with the noun;
now examine text printed is true.
now examine text printed is true.
Report switching on something:
say "You flip a switch. ";
carry out the showing action activity with the noun instead.
@ -140,7 +143,7 @@ But all of those details are re-copied from the standard rules, and the importan
Rule for printing the room-description of a room when the player wears the sunglasses:
say "The walls look like they're covered with ants. Just a coincidence, I'm sure[antsy]."
Rule for printing the room-description of the Kitchen when the player wears the sunglasses:
say "Are ants coming out of the sink? No, probably not[antsy]."
@ -149,11 +152,11 @@ But all of those details are re-copied from the standard rules, and the importan
Rule for showing action of the microwave:
say "The microwave hums meaningfully to itself."
Rule for showing action of the microwave when the player wears the sunglasses:
say "The microwave hums as though inhabited by a billion ants[antsy]."
The player carries sunglasses of freakiness and an apple. The apple is edible. The sunglasses are wearable.
The player carries sunglasses of freakiness and an apple. The apple is edible. The sunglasses are wearable.
ant-paranoia is a number that varies.

View file

@ -1,9 +1,12 @@
** Stored actions
(Device to remember and play back actions; Anteaters)
The player carries a gizmo that is able to record actions performed by the player, then force them to repeat those actions when the gizmo is dropped. This includes storing actions that apply to topics, as in "look up anteater colonies in the guide".
Example: ** Anteaters
Location: Stored actions
RecipeLocation: Remembering, Converting and Combining Actions
Index: Device to remember and play back actions
Description: The player carries a gizmo that is able to record actions performed by the player, then force them to repeat those actions when the gizmo is dropped. This includes storing actions that apply to topics, as in "look up anteater colonies in the guide".
For: Z-Machine
{*} "Anteaters"
A book is a kind of thing. Understand "book" as a book. A book has a table name called the contents.
Report consulting a book about:

View file

@ -1,64 +0,0 @@
* Asking which do you mean
(Disambiguation question giving items more explicit names; Apples)
Prompting the player on how to disambiguate otherwise similar objects.
Inform by default detects whether two objects can be disambiguated by any vocabulary available to the player. If so, it asks a question; if not, it picks one of the identical objects at random.
Generally this produces good behavior. Occasionally, though, two objects have some distinguishing characteristic that doesn't appear in the object name. For instance, suppose we've created a class of apples that can be told apart depending on whether they've been bitten or not:
An apple is a kind of thing. Consumption is a kind of value. The consumptions are pristine and bitten. An apple has a consumption. The description of an apple is "It is [consumption]."
Understand the consumption property as describing an apple.
The player can meaningfully type
>EAT BITTEN APPLE
or
>EAT PRISTINE APPLE
but if they type
>EAT APPLE
Inform will, annoyingly, ask
Which do you mean, an apple or the apple?
This gives the player no indication of why Inform is making a distinction. So here we add a special "printing the name" rule to get around that situation:
{*} "Apples"
Orchard is a room.
An apple is a kind of thing. Consumption is a kind of value. The consumptions are pristine and bitten. An apple has a consumption. The description of an apple is "It is [consumption]."
Understand the consumption property as describing an apple.
Before printing the name of an apple while asking which do you mean: say "[consumption] ". Before printing the plural name of an apple while asking which do you mean: say "[consumption] ".
The player carries three apples.
Instead of eating a pristine apple (called the fruit):
say "You take a satisfying bite.";
now the fruit is bitten.
Instead of eating a bitten apple (called the fruit):
say "You consume the apple entirely.";
now the fruit is nowhere.
Inform will also separate the bitten from the pristine apples in inventory listings and room descriptions, even though it's not clear why; we can improve on that behavior thus:
{**}Before listing contents: group apples together.
Rule for grouping together an apple (called target):
let source be the holder of the target;
say "[number of apples held by the source in words] apple[s], some bitten".
Before printing the plural name of an apple (called target):
let source be the holder of the target;
if every apple held by the source is bitten, say "bitten ";
if every apple held by the source is pristine, say "pristine ".
Test me with "i / eat apple / i / eat apple / pristine / i / eat apple / pristine / i".

View file

@ -0,0 +1,67 @@
Example: * Apples
Location: Asking which do you mean
RecipeLocation: Clarification and Correction
Index: Disambiguation question giving items more explicit names
Description: Prompting the player on how to disambiguate otherwise similar objects.
For: Z-Machine
Inform by default detects whether two objects can be disambiguated by any vocabulary available to the player. If so, it asks a question; if not, it picks one of the identical objects at random.
Generally this produces good behavior. Occasionally, though, two objects have some distinguishing characteristic that doesn't appear in the object name. For instance, suppose we've created a class of apples that can be told apart depending on whether they've been bitten or not:
An apple is a kind of thing. Consumption is a kind of value. The consumptions are pristine and bitten. An apple has a consumption. The description of an apple is "It is [consumption]."
Understand the consumption property as describing an apple.
The player can meaningfully type
>EAT BITTEN APPLE
or
>EAT PRISTINE APPLE
but if they type
>EAT APPLE
Inform will, annoyingly, ask
Which do you mean, an apple or the apple?
This gives the player no indication of why Inform is making a distinction. So here we add a special "printing the name" rule to get around that situation:
{*} "Apples"
Orchard is a room.
An apple is a kind of thing. Consumption is a kind of value. The consumptions are pristine and bitten. An apple has a consumption. The description of an apple is "It is [consumption]."
Understand the consumption property as describing an apple.
Before printing the name of an apple while asking which do you mean: say "[consumption] ". Before printing the plural name of an apple while asking which do you mean: say "[consumption] ".
The player carries three apples.
Instead of eating a pristine apple (called the fruit):
say "You take a satisfying bite.";
now the fruit is bitten.
Instead of eating a bitten apple (called the fruit):
say "You consume the apple entirely.";
now the fruit is nowhere.
Inform will also separate the bitten from the pristine apples in inventory listings and room descriptions, even though it's not clear why; we can improve on that behavior thus:
{**}Before listing contents: group apples together.
Rule for grouping together an apple (called target):
let source be the holder of the target;
say "[number of apples held by the source in words] apple[s], some bitten".
Before printing the plural name of an apple (called target):
let source be the holder of the target;
if every apple held by the source is bitten, say "bitten ";
if every apple held by the source is pristine, say "pristine ".
Test me with "i / eat apple / i / eat apple / pristine / i / eat apple / pristine / i".

View file

@ -1,35 +0,0 @@
*** Text with numbers
(Saying a number in round numbers; Ballpark)
A new "to say" definition which allows the author to say "[a number in round numbers]" and get verbal descriptions like "a couple of" or "a few" as a result.
Sometimes it is more sensible to describe numbers roughly than in exact terms. For instance, we might want to have our player perceive "many people" rather than "forty-two people" on entering a room. To achieve this, we might write our own "to say" phrase.
{*}"Ballpark"
To say (count - a number) in round numbers:
repeat through the Table of Numerical Approximation:
if count is less than threshold entry:
say "[approximation entry]";
rule succeeds.
Phrases will be explained more thoroughly in a later chapter, but as we have already seen in the examples, we can make a "To say..." phrase that will allow us to create our own text substitutions. In this case, we are going to replace the specific number with a vaguer one chosen from a chart, so:
{**}Table of Numerical Approximation
threshold approximation
1 "no"
2 "one"
3 "a couple of"
6 "a few"
11 "some"
21 "many"
1000 "lots and lots of"
The idea here is that we will work our way through the table until we hit a line where the threshold number is higher than the number we want to express, and then print that output: so if we have less than one item, we'll print "no"; if we have more than none but less than two, we'll print "one"; if we have less than three, we'll print "a couple of"; if we have three, four, or five (but not six), we'll print "a few."
{**}A room has a number called the population. The population of a room is usually 0. The description of a room is usually "You observe [population of the location in round numbers] [if population of the location is 1]person [otherwise]people [end if]here.".
The Stadium is a room. The Hot Dog Stand is west of the Stadium. The Women's Restroom is south of the Stadium.
The population of the Stadium is 500. The population of the Hot Dog Stand is 3. The population of the Restroom is 750.
Test me with "w / e / s".

View file

@ -1,22 +0,0 @@
* Adjacent rooms and routes through the map
(Person who moves randomly; Mistress of Animals)
A person who moves randomly between rooms of the map.
Suppose we want a restless sort of character always pacing from room to room. It is quite easy to use adjacency to achieve this effect:
{*}"Mistress of Animals"
Corinth is a room. Athens is east of Corinth. Epidaurus is southeast of Corinth and east of Mycenae. Mycenae is south of Corinth. Olympia is west of Mycenae. Argos is south of Mycenae. Thebes is northwest of Athens. Pylos is south of Olympia. Sparta is east of Pylos and south of Argos. Delphi is northwest of Thebes.
Artemis is a woman in Thebes.
Every turn:
if Artemis is in a room (called the current space):
let next space be a random room which is adjacent to the current space;
if Artemis is visible, say "Artemis heads to [the next space].";
move Artemis to next space;
if Artemis is visible, say "Artemis arrives from [the current space]."
Test me with "z / z / z / z / z / z".
Of course, it helps that Artemis is the sort to like open spaces. The implementation would become more complicated if there were doors which might block transit between these locations.

View file

@ -1,17 +1,20 @@
* Understanding things by their properties
(Understanding units as part of the name of a thing--Television with aspect ratio; Aspect)
Understanding aspect ratios (a unit) in the names of televisions.
Example: * Aspect
Location: Understanding things by their properties
RecipeLocation: Televisions and Radios
Index: Understanding units as part of the name of a thing
Description: Understanding aspect ratios (a unit) in the names of televisions.
For: Z-Machine
Named properties are not the only kind that Inform is able to understand referring to an object. We can also use unit and number properties to distinguish things from one another, as here, where televisions have aspect ratios:
{*}"Aspect"
An aspect ratio is a kind of value. 16:9 specifies an aspect ratio.
A television is a kind of device. A television has an aspect ratio. Understand the aspect ratio property as referring to a television. Understand "European standard" as 16:9.
The Office is a room.
The Office is a room.
The widescreen TV is a television in the Office. The fifties TV is a television in the Office. The widescreen TV is 16:9. The fifties TV is 4:3.
The widescreen TV is a television in the Office. The fifties TV is a television in the Office. The widescreen TV is 16:9. The fifties TV is 4:3.
Test me with "examine european standard tv / x 16:9 tv / x 4:3 tv".
Test me with "examine european standard tv / x 16:9 tv / x 4:3 tv".

View file

@ -1,39 +0,0 @@
*** Adjacent rooms and routes through the map
(LOOK [direction] command; A View of Green Hills)
A LOOK [direction] command which allows the player to see descriptions of the nearby landscape.
Suppose a game in which the player is wandering an open landscape with long vistas, allowing them to LOOK in some direction, or even look at an adjacent location.
{*}"A View of Green Hills"
Corinth is a room. Athens is east of Corinth. Epidaurus is southeast of Corinth and east of Mycenae. Mycenae is south of Corinth. Olympia is west of Mycenae. Argos is south of Mycenae. Thebes is northwest of Athens. Pylos is south of Olympia. Sparta is east of Pylos and south of Argos. Delphi is northwest of Thebes.
Understand "look [direction]" as facing.
Facing is an action applying to one visible thing.
Carry out facing:
let the viewed item be the room noun from the location;
if the viewed item is not a room, say "You can't see anything promising that way." instead;
try looking toward the viewed item.
In rules about action handling, "noun" refers to the first object that the player has mentioned in their command, so if the player typed >LOOK WEST, "let the viewed item be the room noun from the location" would be processed as "let the viewed item be the room west from the location", and so on.
We can at need override the default behavior, if it is not going to be appropriate for the player to see the next room over. There is only sky above at any time, so...
{**}Instead of facing up:
say "Above you is bright sky."
Understand "look toward [any adjacent room]" as looking toward. Understand "examine [any adjacent room]" as looking toward.
Looking toward is an action applying to one visible thing.
Carry out looking toward:
say "You make out [the noun] that way."
This design allows us to create descriptions for rooms (as seen from the outside) which will work regardless of where we're looking from. For instance:
{**}Instead of looking toward Athens:
say "Even from here you can make out the silhouette of the Acropolis."
Test me with "look north / look south / look up / look east / east / look west".

View file

@ -1,17 +0,0 @@
*** Text with variations
(Door kind that describes the destination; Whence?)
A kind of door that always automatically describes the direction it opens and what lies on the far side (if that other room has been visited).
It would be fairly tedious reading to have a large game full of doors that describe themselves this way. Nonetheless, if we insisted we could use our knowledge of the map as leverage to make every door in the game describe itself automatically.
To do this, we make use of the phrase "direction of (the door) from (a room)" -- in this case, the direction of the door we're looking at when viewed from the player's location. Thus:
{*}"Whence?"
The temporal vortex is an open door. It is west of Yesterday and east of Today.
The initial appearance of a door is usually "Nearby [an item described] leads [if the other side of the item described is visited][direction of the item described from the location] to [the other side of the item described][otherwise][direction of the item described from the location][end if]."
Test me with "w / e".
Yet a further variation on this, which can automatically understand "the east door" and "the west door" when appropriate, may be found in the example "Whither?".

View file

@ -0,0 +1,15 @@
Example: * Bad Hair Day
Location: Instead rules
RecipeLocation: Characterization
Index: Examining the player
Description: Change the player's appearance in response to EXAMINE ME.
For: Z-Machine
{*}"Bad Hair Day"
The Foyer is a room. "A mirror hangs over the table, tempting you to check your appearance before going in with all the others."
Instead of examining the player:
say "Oh, stop fussing. You look fine."
Test me with "examine me".

View file

@ -0,0 +1,32 @@
Example: * Baedeker
Location: Titling and abbreviation
RecipeLocation: Publishing
Index: Producing an EPS floorplan
Description: Creating a floorplan of the cathedral using the locations from previous examples.
For: Z-Machine
If our map is largely or entirely set inside a single building, we might want to produce something that resembles a floorplan. It's possible to do this with a little tweaking, like so:
{*}"Baedeker"
Dome is a room. North of Dome is North Chapel. South of the Dome is South Chapel. West of the Dome is Western End. Quiet Corner is northwest of the Dome, north of Western End, and west of North Chapel. Loud Corner is east of North Chapel, northeast of Dome, and north of Eastern End. Eastern End is north of Dim Corner and east of Dome. Dim Corner is southeast of Dome and east of South Chapel. Ruined Corner is southwest of Dome, west of South Chapel, and south of Western End.
The church door is east of Eastern End and west of the Courtyard. The church door is a door.
Index map with
room-shape set to "square" and
room-size set to 60 and
room-name-size set to 9 and
room-name-length set to 13 and
route-thickness set to 20 and
room-outline set to off and
map-outline set to off and
route-colour set to "White" and
room-colour set to "White" and
room-shape of Dome set to "circle" and
room-size of Dome set to 80 and
EPS file.
Now we have a map made of white lines and boxes over a white background, which is not very exciting. If, however, we put a layer of black under this and slightly adjust the room shapes (using an image editor such as Adobe Illustrator), we can produce something that plausibly resembles a floorplan or museum map, like so:
///Sophia.jpg///

View file

@ -0,0 +1,38 @@
Example: *** Ballpark
Location: Text with numbers
RecipeLocation: Varying What Is Written
Index: Saying a number in round numbers
Description: A new "to say" definition which allows the author to say "[a number in round numbers]" and get verbal descriptions like "a couple of" or "a few" as a result.
For: Z-Machine
Sometimes it is more sensible to describe numbers roughly than in exact terms. For instance, we might want to have our player perceive "many people" rather than "forty-two people" on entering a room. To achieve this, we might write our own "to say" phrase.
{*}"Ballpark"
To say (count - a number) in round numbers:
repeat through the Table of Numerical Approximation:
if count is less than threshold entry:
say "[approximation entry]";
rule succeeds.
Phrases will be explained more thoroughly in a later chapter, but as we have already seen in the examples, we can make a "To say..." phrase that will allow us to create our own text substitutions. In this case, we are going to replace the specific number with a vaguer one chosen from a chart, so:
{**}Table of Numerical Approximation
threshold approximation
1 "no"
2 "one"
3 "a couple of"
6 "a few"
11 "some"
21 "many"
1000 "lots and lots of"
The idea here is that we will work our way through the table until we hit a line where the threshold number is higher than the number we want to express, and then print that output: so if we have less than one item, we'll print "no"; if we have more than none but less than two, we'll print "one"; if we have less than three, we'll print "a couple of"; if we have three, four, or five (but not six), we'll print "a few."
{**}A room has a number called the population. The population of a room is usually 0. The description of a room is usually "You observe [population of the location in round numbers] [if population of the location is 1]person [otherwise]people [end if]here.".
The Stadium is a room. The Hot Dog Stand is west of the Stadium. The Women's Restroom is south of the Stadium.
The population of the Stadium is 500. The population of the Hot Dog Stand is 3. The population of the Restroom is 750.
Test me with "w / e / s".

View file

@ -1,57 +0,0 @@
** Repeat running through
(People who interact with each other each turn; Strictly Ballroom)
People who select partners for dance lessons each turn.
Many simple repetitions can effectively be done with a "now..." instruction: it is quicker to say
now every person is angry
than
repeat with offended party running through people:
now the offended party is angry.
Repeat comes in handy when we have something a bit more complicated to do with each item:
{*}"Strictly Ballroom"
A person can be alert or occupied. A person is usually alert.
When play begins:
now the player is occupied.
Dance is a kind of value. The dances are waltzes, polkas, cha-chas, charlestons, fox-trots, tangos, lambadas, and two-steps.
The current round is a dance that varies.
Manner is a kind of value. The manners are swiftly, primly, energetically, suavely, seductively, elegantly, and badly.
Every turn: now the current round is a random dance.
Every turn:
repeat with dancer running through people who are not the player:
if dancer is alert:
now dancer is occupied;
let partner be a random alert person who is not the dancer;
if partner is a person:
now partner is occupied;
say "[The dancer] [the current round][if a random chance of 1 in 5 succeeds] [a random manner][end if] with [partner]. ";
otherwise:
say "[paragraph break][The dancer] is forced to be a wallflower. Poor [dancer]. ";
say paragraph break.
Notice we did not say "repeat with dancer running through alert people who are not the player...". This is because Inform would draw up a list of alert people at the beginning of the repeat, and not take into account which people became occupied partway through the repetition. If we want to make sure that each person dances only with one other person, we have to continue checking alertness each time we run through the repetition.
After all the partners are assigned, we can set up for the next turn by making everyone alert again, and for this we do not need "repeat":
{**}Every turn: now every person is alert; now the player is occupied.
Before doing something to someone: now the noun is occupied.
Before doing something when the second noun is a person: now the second noun is occupied.
Instead of doing something to someone: say "You successfully distract [the noun]."
The Pacific Ballroom is a room. "A rather utilitarian space at the moment, since this is a class and not a party." Timmy, Tommy, Joey, George, Mary, Martha, Yvette, McQueen, Linus, and Patricia are people in the Pacific Ballroom.
Test me with "z / ask linus about blanket / z / z".

View file

@ -1,79 +0,0 @@
** Arithmetic with units
(OFFER price FOR command allowing player to bargain; Money for Nothing)
An OFFER price FOR command, allowing the player to bargain with a flexible seller.
{*}"Money for Nothing"
Section 1 - Prices and Bargaining
Price is a kind of value. $10.99 specifies a price with parts dollars and cents (optional, preamble optional).
A person has a price called wealth. The wealth of the player is $15.
A thing has a price called minimum value. The minimum value of a thing is usually $0.50.
A thing has a price called desired value. The desired value of a thing is usually $5.00.
Offering it for is an action applying to one price and one visible thing.
Understand "offer [price] for [something]" as offering it for.
After taking inventory, say "You have [the wealth of the player]."
Check offering it for:
if the price understood is greater than the wealth of the player, say "You don't have that kind of cash." instead;
if the second noun is not carried by someone, say "There's no one in a position to sell you [the second noun]." instead;
if the second noun is carried by the player, say "[The second noun] is already yours." instead;
if the minimum value of the second noun is greater than the price understood, say "[The holder of the second noun] cackles disdainfully. 'If yer just here to insult me you can take your business elsewhere!' he says." instead;
if the desired value of the second noun is greater than the price understood:
let difference be the desired value of the second noun minus the price understood;
let difference be difference divided by two;
decrease the desired value of the second noun by difference;
now the last object offered is the second noun;
say "'How about [desired value of the second noun]?' suggests [the holder of the second noun]." instead;
otherwise:
unless the desired value of the second noun is the price understood:
say "From the avaricious gleam in the eye of [the holder of the second noun], you guess you could've gotten this purchase for less..."
Carry out offering it for:
increase the wealth of the holder of the second noun by the price understood;
decrease the wealth of the player by the price understood;
move the second noun to the player.
Report offering it for:
say "You spend [the price understood], and now you possess [the second noun]."
When play begins: now right hand status line is "Your funds: [wealth of the player]".
Now, since the man does make counter-offers, it would be reasonable to let the player accept or reject those, as well:
{**}The last object offered is a thing that varies.
Instead of saying yes when the last object offered is carried by a person (called seller) who is not the player:
if the seller is not visible:
continue the action;
otherwise:
now the price understood is the desired value of the last object offered;
try offering the desired value of the last object offered for the last object offered.
Instead of saying no when the last object offered is carried by a person (called seller) who is not the player:
if the seller is not visible:
continue the action;
otherwise:
now the last object offered is the player;
say "You reject the offer firmly."
And we borrow just a line or two from a later chapter to take care of some alternate syntax the player might try:
{**}Understand "offer [price] to [someone]" as a mistake ("You'll need to specify what you want to buy -- try OFFER $1000.00 FOR BROOKLYN BRIDGE."). Understand "offer [someone] [price]" as a mistake ("You'll need to specify what you want to buy -- try OFFER $1000.00 FOR BROOKLYN BRIDGE.").
Understand "buy [something]" as a mistake ("You'll have to name your price: try OFFER $1000.00 FOR BROOKLYN BRIDGE.").
Section 2 - The Scenario
The Flea Market is a room. The crotchety man is a man in the Market. "A crotchety man here is selling [the list of things carried by the crotchety man]." The crotchety man carries a broken television set, a Victorian rhinestone brooch, and a cracked shaving mug.
The minimum value of the brooch is $2.50.
Test me with "offer $0.50 for mug / offer $0.50 to man / offer $6.00 for mug / offer $50.00 for brooch / offer $1.50 for brooch / offer $4.50 for brooch / no / offer $4.50 for brooch / yes".

View file

@ -1,16 +1,19 @@
*** Understanding values
(Allowing the player to describe the main character before starting play; Baritone, Bass)
Letting the player pick a gender (or perhaps other characteristics) before starting play.
Example: *** Baritone, Bass
Location: Understanding values
RecipeLocation: Traits Determined By the Player
Index: Allowing the player to describe the main character before starting play
Description: Letting the player pick a gender (or perhaps other characteristics) before starting play.
For: Z-Machine
The "reading a command" activity is rather advanced; for the moment, what we need to understand is that we're intervening in commands at the start of play and insisting that the player's first instruction to the game consist of a choice of gender. After that point, the gender will be set and play will proceed as normal.
In order to do the parsing, we define gender as a kind of value, and give several alternate names to each gender.
{*}"Baritone, Bass"
Getting Started is a room.
Gender is a kind of value. The genders are masculine, feminine, and unknown. Understand "male" or "man" or "M" as masculine. Understand "female" or "woman" or "F" as feminine.
Gender is a kind of value. The genders are masculine, feminine, and unknown. Understand "male" or "man" or "M" as masculine. Understand "female" or "woman" or "F" as feminine.
A person has a gender. The gender of the player is unknown.
@ -32,20 +35,20 @@ In order to do the parsing, we define gender as a kind of value, and give severa
otherwise:
say "Sorry, we're not ready to go on yet. [run paragraph on]";
reject the player's command.
Sandy Beach is a room.
Instead of examining the player when the player is female:
Sandy Beach is a room.
Instead of examining the player when the player is female:
say "Congratulations, you are a girl!"
Instead of examining the player when the player is male:
Instead of examining the player when the player is male:
say "Congratulations, you are a boy!"
If we had a whole series of things to ask the player about, we might define a whole series of kinds of value
If we had a whole series of things to ask the player about, we might define a whole series of kinds of value
The vocal ranges are soprano, mezzosoprano, contralto...
and use a "construction stage" variable to keep track of the current stage of character-construction, as in
After reading a command when the current construction stage is choosing a vocal range:
...
...

View file

@ -1,41 +0,0 @@
*** Check rules for actions by other people
(GIVE action for other characters; Barter Barter)
Allowing characters other than the player to give objects to one another, accounting for the possibility that some items may not be desired by the intended recipients.
By default, if we make no modifications, telling one player to give something to another will fail, even if persuasion succeeds. This is because the default behavior of the GIVE command is interrupted by the "block giving rule" -- since in many cases we do not want people to exchange objects freely.
However, suppose that we do want characters to be able to exchange articles freely: we allow persuasion to succeed and turn off the "block giving rule".
{*}"Barter Barter"
The block giving rule is not listed in the check giving it to rules.
A persuasion rule for asking people to try giving: persuasion succeeds.
The Trading Post is a room.
Meriwether Lewis is a man in the Trading Post. He carries a fluffy handmade quilt and a bag of beans. The beans are edible.
William Clark is a man in the Trading Post. He carries leather slippers, a journal, and a loaf of bread. The bread is edible. The slippers are wearable.
Instead of examining someone:
say "[The noun] is carrying [the list of things carried by the noun]."
And now we might want to implement a way to keep track of whether the recipient character wants what's being offered:
{**}Check someone trying giving something to someone (this is the sneering refusal rule):
if the second noun dislikes the noun, stop the action.
Unsuccessful attempt by someone trying doing something:
if the reason the action failed is the sneering refusal rule, say "'Would you care for [the noun]?' [the person asked] asks solicitously of [the second noun].
But [the second noun] refuses [the noun] disdainfully.";
otherwise say "[The person asked] just appears bewildered by this improbable instruction."
Distaste relates one person to various things. The verb to dislike means the distaste relation.
Clark dislikes the beans. Lewis dislikes the bread.
Since we've defined this as a relation, we could change what the characters like and dislike during the course of the game, freely; for instance, characters might grow hungry and suddenly like all the edible articles.
{**}Test me with "x lewis / x clark / clark, give the slippers to lewis / clark, give the bread to lewis".

Some files were not shown because too many files have changed in this diff Show more