|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Tue Sep 28, 2010 9:38 pm
[3.29b] dbvar pattern skipping values |
I made these setting in a empty session:
Code: |
<var name="numbers" type="Record" id="1">
<value>one=1|two=2|three=3|four=4|five=5</value>
<json>{"two":2,"one":1,"three":3,"four":4,"five":5}</json>
</var>
<trigger priority="20" repeat="true" id="2">
<pattern>({@numbers})</pattern>
<value><![CDATA[$num=%1;#SUB {<send '#SAY {$num equals @numbers.$num}|#NOOP' 'What was i?|Nothing'><color firebrick>@numbers.$num</color></send>}]]></value>
</trigger> |
For some reason this seems to be skipping some values. I entered the following commands:
#SAY {one}
#SAY {one two three four}
#SAY {'one' 'two' 'three' 'four'}
#SAY {'one' 'two' 'three' 'four' 'five'}
And got the following output:
I found this trying to reproduce the error in a more complicated script that is completely hanging CMUD.
P.S. Why is the json value in a different order then the normal value in the XML for the variable? |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Sep 29, 2010 5:40 pm |
Confirmed and added to bug list.
Quote: |
P.S. Why is the json value in a different order then the normal value in the XML for the variable? |
Because JSON stores values in order of it's hash algorithm and doesn't have any knowledge of the order the items were actually added to the list. Whereas the normal value of the variable tries to keep track of the creation order (at least within the session the variable was created). In general you should not rely upon the order of items in a database variable. |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Wed Sep 29, 2010 6:02 pm |
But you can still reference them via position (aka %isvalue() and %dbkey()) which definitely good to note.
|
|
|
|
|
|