 |
Martaigne Wanderer
Joined: 05 Jan 2002 Posts: 88 Location: Atlanta, GA
|
Posted: Wed Jun 16, 2010 6:09 am
[3.19e] %delitem deletes all instances of item instead of first - FIXED |
Just discovered this while working on a script. As per the documentation, "delete item s from the given string list. If there are duplicate items, only the first is removed." It's easy to demonstrate.
Create an alias 'delitem':
Code: |
#LOOP 4 {
stringlist = %additem("one", @stringlist)
}
stringlist = %additem("two", @stringlist)
#LOOP 4 {
stringlist = %additem("one", @stringlist)
}
#SHOW @stringlist
stringlist = %delitem("one", @stringlist)
#SHOW @stringlist
|
Output will be:
Quote: |
one|one|one|one|two|one|one|one|one
two
|
Output SHOULD be:
Quote: |
one|one|one|one|two|one|one|one|one
one|one|one|two|one|one|one|one
|
|
|
_________________ Unwritten Legends
Last edited by Martaigne on Thu Jun 17, 2010 11:10 pm; edited 1 time in total |
|
|
 |
charneus Wizard

Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Wed Jun 16, 2010 7:54 am |
To elaborate further on this, this only happens with global variables.
Changing all the @ to $ to make it a local variable, it reports output correctly.
Alias:
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<alias name="testdel" copy="yes">
<value>#LOCAL stringlist
#PRINT {Test case one with global variable:}
#LOOP 4 {
stringlist = %additem("one", @stringlist)
}
#PRINT {Global variable with four ones in it:%cr@stringlist}
stringlist = %additem("two", @stringlist)
#PRINT {Global variable with four ones and one two in it:%cr@stringlist}
#LOOP 4 {
stringlist = %additem("one", @stringlist)
}
#PRINT {Global variable with four ones followed by one two ending with four ones:%cr@stringlist}
stringlist = %delitem("one", @stringlist)
#PRINT {Global variable should only be missing one one, but it is missing all:%cr@stringlist}
#PRINT {Test case two with local variable:}
#LOOP 4 {
$stringlist = %additem("one", $stringlist)
}
#PRINT {Local variable with four ones in it:%cr$stringlist}
$stringlist = %additem("two", $stringlist)
#PRINT {Local variable with four ones and one two in it:%cr$stringlist}
#LOOP 4 {
$stringlist = %additem("one", $stringlist)
}
#PRINT {Local variable with four ones followed by one two ending with four ones:%cr$stringlist}
$stringlist = %delitem("one", $stringlist)
#PRINT {Local variable correctly displayed with only one missing one:%cr$stringlist}</value>
</alias>
</cmud>
|
Test cases:
Code: |
Test case one with global variable:
Global variable with four ones in it:
one|one|one|one
Global variable with four ones and one two in it:
one|one|one|one|two
Global variable with four ones followed by one two ending with four ones:
one|one|one|one|two|one|one|one|one
Global variable should only be missing one one, but it is missing all:
two
Test case two with local variable:
Local variable with four ones in it:
one|one|one|one
Local variable with four ones and one two in it:
one|one|one|one|two
Local variable with four ones followed by one two ending with four ones:
one|one|one|one|two|one|one|one|one
Local variable correctly displayed with only one missing one:
one|one|one|two|one|one|one|one |
Charneus |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Jun 16, 2010 4:33 pm |
Confirmed and added to bug list. Not sure why it would be any different with local variables. Very odd.
|
|
|
 |
Martaigne Wanderer
Joined: 05 Jan 2002 Posts: 88 Location: Atlanta, GA
|
Posted: Thu Jun 17, 2010 11:11 pm |
Appears to be fixed.
|
|
|
 |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|