loopsdictionaryglobal-variablesaimlpandorabots

Body of AIML <condition> loop fails to execute in Pandorabots


I'm trying to loop through a list using AIML in Pandorabots, with the standard library, via MS Edge on an up-to-date Windows 11.

All of the following code occurs within the same <think> tags.

There's another loop immediately prior to this one. These two loops are functionally identical. Each loop references a different map of zero-based indices to predicate names, in order to set all the predicate values to "unknown".

The only difference is the two map files; the only difference between them is case and (trivial) string length, and they both work in other contexts:

[["0", "HI"], ["1", "BY"], ["2", "OK"], [ ... ]] and [["0", "hello"], ["1", "byenow"], ["2", "okay"], [ ... ]]

So the first loop works, but then this one does apparently nothing:

<set var="i">0</set>
<set var="allreset">FALSE</set>
<condition var="allreset" value="FALSE">

    <!-- reset predicate -->
    <set><name><map name="thingsdict"><get var="i" /></map></name>
        unknown
    </set>

    <!-- increment and check for OOR -->
    <set var="i"><map name="successor"><get var="i" /></map></set>
    <set var="allreset">
        <srai>XEQ <map name="thingsdict"><get var="i" /></map> XS unknown</srai>
    </set>
    <loop />
</condition>

Here's the previous loop, the one that works correctly:

<set var="i">0</set>
<set var="allreset">FALSE</set>
<condition var="allreset" value="FALSE">

    <!-- reset predicate -->
    <set><name><map name="otherthingsdict"><get var="i" /></map></name>
        unknown
    </set>

    <!-- increment and check for OOR -->
    <set var="i"><map name="successor"><get var="i" /></map></set>
    <set var="allreset">
        <srai>XEQ <map name="otherthingsdict"><get var="i" /></map> XS unknown</srai>
    </set>
    <loop />
</condition>

Literally identical, no?

EDIT: Full category (with think tags commented out for debug):

<category>
    <pattern>5</pattern>
    <template>
        Starting over...
        <br/><br/>
        <!--<think>-->
            <set name="mode">unknown</set>
            <set name="score">unknown</set>
            <set name="ties">unknown</set>
            <set name="tiecount">unknown</set>
            
            <!-- loop through first map of related predicates -->
            <set var="i">0</set>
            <set var="allreset">FALSE</set>
            <condition var="allreset" value="FALSE">
                <map name="thingsdict"><get var="i" /></map>
                <set><name><map name="thingsdict"><get var="i" /></map></name>
                    unknown
                </set>
                <set var="i"><map name="successor"><get var="i" /></map></set>
                <set var="allreset">
                    <srai>XEQ <map name="thingsdict"><get var="i" /></map> XS unknown</srai>
                </set>
                <loop />
            </condition>
            
            <!-- loop through other related predicates -->
            <set var="i">0</set>
            <set var="allreset">FALSE</set>
            <condition var="allreset" value="FALSE">
                <map name="otherthingsdict"><get var="i" /></map>
                <set><name><map name="otherthingsdict"><get var="i" /></map></name>
                    unknown
                </set>
                <set var="i"><map name="successor"><get var="i" /></map></set>
                <set var="allreset">
                    <srai>XEQ <map name="otherthingsdict"><get var="i" /></map> XS unknown</srai>
                </set>
                <loop />
            </condition>
        <!--</think>-->
        All values erased!
        <br/><br/>
        <srai>HI</srai>
    </template>
</category>

Thanks in advance for any help!


Solution

  • Any <loop/> tag must occur within <li> tags. Be sure to include a set of <li> tags without a <loop/> element as well; these can be empty or not.