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
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Fri May 28, 2010 6:59 pm   

[3.18c]BUG: %numitems doesn't recognize @var.key syntax any longer (Resurfaced)
 
I still use %eval in a number of scripts (just because it makes it easier for me to see where I'm doing the math half the time, and plus, sometimes just the () alone doesn't do the job, so I hate having to keep remembering when I can use it and when I can't. Anyway, to the subject at hand, best way I know to test this is with this:

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <var name="testdb" type="Record" copy="yes">key1=1</var>
  <alias name="test" copy="yes">
    <value>#IF (%eval(@testdb.key1-1)) {#SAY {True}} {#SAY {False}}</value>
  </alias>
</cmud>


Simply place that into an untitled session, then type test on the command line. Since the value is 1 for record key1, it returns false, which seems normal.

However, type #ADDKEY TestDB key1 2 and type test on the line, and it still returns false, which is not true because 2-1 equals 1, which would make the expression true. This will probably break a few scripts, too.

Charneus

Edit: This is actually true with trying to evaluate even without the %eval. I changed the alias to do $Test=(@testdb.key1-1);#IF ($Test) {#SAY {True}} {#SAY {False}} and it still didn't work.


Last edited by charneus on Fri Jun 04, 2010 12:42 am; edited 3 times in total
Reply with quote
Tech
GURU


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

PostPosted: Fri May 28, 2010 8:04 pm   
 
This is not a bug. You need to put a space between the '-' and 'key1'. Since '-' can be a valid character in a variable name the eval is looking up "@testdb.key1-1" and not evaluate "@testdb.key1 minus 1".

This code works just fine.

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <alias name="test" copy="yes">
    <value>#IF (%eval(@testdb.key1 - 1) == 0) {#SAY {True}} {#SAY {False}}
</value>
  </alias>
  <var name="testdb" type="Record" copy="yes">key1=1</var>
</cmud>
_________________
Asati di tempari!
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Fri May 28, 2010 9:12 pm   
 
You're right, and in fact, my script is correctly formatted as such.

The actual problem lies in %numitems, not %eval.

Code:
#ADDKEY TestDB Key1 {1|2|3|4|5}
#SAY {%numitems(@TestDB.Key1)}
#SAY {%numitems(%db(@TestDB, Key1))}


returns:

Code:
1
5


Charneus
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Fri May 28, 2010 9:18 pm   
 
As a secondary note, %item(@TestDB.Key1, 1) no longer works, either.

Charneus
Reply with quote
Zugg
MASTER


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

PostPosted: Fri May 28, 2010 10:42 pm   
 
Confirmed. At least this is more of the kind of stuff that I *expected* to be broken (as opposed to stuff like #gag suddenly not working).
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Fri Jun 04, 2010 12:40 am   
 
This bug has resurfaced, only now it doesn't work, period.

Code:
#ADDKEY TestDB Test {1|2|3|4|5}
#SAY {%numitems(@TestDB.Test)}
#SAY {%numitems(%db(@TestDB, Test))}


shows '1' as the number of items in each case.

Charneus


Last edited by charneus on Fri Jun 04, 2010 9:52 pm; edited 1 time in total
Reply with quote
Zugg
MASTER


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

PostPosted: Fri Jun 04, 2010 1:04 am   
 
Hmm, weird...I thought I had that in my test script already. Btw, you are missing a ) paren on the last line. But I reproduced that this is only returning a value of 1 for some reason. Looks like I broke as much as I fixed again :(
Reply with quote
Zugg
MASTER


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

PostPosted: Fri Jun 04, 2010 5:27 pm   
 
Interesting on this one. It only fails if the variable doesn't exist yet. If you run the test twice, it works the second time. Found it and got it fixed for the next version.
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Fri Jun 04, 2010 6:42 pm   
 
Zugg wrote:
Interesting on this one. It only fails if the variable doesn't exist yet. If you run the test twice, it works the second time. Found it and got it fixed for the next version.


That is interesting - at first, I thought you were talking about running the %numitems part twice, not the entire thing. So essentially, you have to populate the variable twice before it will work... Fun. Thanks for getting this taken care of, though!

Charneus
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