Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
GeneralStonewall
Magician


Joined: 02 Feb 2004
Posts: 364
Location: USA

PostPosted: Tue Jun 29, 2010 9:39 am   

[3.21] BUG: %item( db.key, i) with single item
 
Hopefully I can explain this in a way that makes sense,

If %item( @db.key, i) is used on a key with a single item it will always return the value, even when i > 1.

code:
Code:
#print ""
#print "---- Setting up variables ----"
#var testdb %null
#var testlist %null
#var testvar %null
#addkey testdb key1 val1
#additem testlist item1
#var testvar "value"
#print {testvar: @testvar}
#print {testdb: %expanddb( @testdb)}
#print {testlist: %expandlist( @testlist)}
#print "---- Using %item( @testvar, 1-3) ----"
#print {%item(@testvar, 1)}
#print {%item(@testvar, 2)}
#print {%item(@testvar, 3)}
#print "---- Using %item( %db( @testdb, key1), 1-3) ----"
#print {%item(%db(@testdb, key1), 1)}
#print {%item(%db(@testdb, key1), 2)}
#print {%item(%db(@testdb, key1), 3)}
#print "---- Using %item( @testdb.key1, 1-3) ----"
#print {%item(@testdb.key1, 1)}
#print {%item(@testdb.key1, 2)}
#print {%item(@testdb.key1, 3)}
#print "---- Using %item( @testlist, 1-3) ----"
#print {%item(@testlist, 1)}
#print {%item(@testlist, 2)}
#print {%item(@testlist, 3)}


output:
Quote:
---- Setting up variables ----
testvar: value
testdb: key1=val1
testlist: item1
---- Using %item( @testvar, 1-3) ----
value


---- Using %item( %db( @testdb, key1), 1-3) ----
val1
val1
val1
---- Using %item( @testdb.key1, 1-3) ----
val1
val1
val1
---- Using %item( @testlist, 1-3) ----
item1
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Tue Jun 29, 2010 1:19 pm   
 
The behavior is confirmed, but I'm not sure if it's a bug or just unexpected behavior. In your example "%db(@testdb, key1)" will always return 'val1'.

How ever val1 is not a defined variable list so %item doesn't know what to do with it so it just spits it back out. If you add the following code snippet you'll see what I mean.

Code:
#print {%db(@testdb, key1)}
#print {%item(foo, 1)}
_________________
Asati di tempari!
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Tue Jun 29, 2010 4:53 pm   
 
Yep. Basically you are running the %db and %item functions on plain string values and not lists or tables. @testdb.key1 is a string value (val1) so it has no concept of items or keys.
Reply with quote
GeneralStonewall
Magician


Joined: 02 Feb 2004
Posts: 364
Location: USA

PostPosted: Tue Jun 29, 2010 8:08 pm   
 
Testvar is a literal string and %item works on it the way I would expect it to, so I don't quite see why using it on %db( @testdb, key1), which should also be a literal string, would not. Also, I don't believe I used %db on a plain string value anywhere.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum All times are GMT
Page 1 of 1

 
Jump to:  
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

© 2009 Zugg Software. Hosted by Wolfpaw.net