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 15, 2010 4:46 am   

[3.19d-] BUG?: @var.key expansion
 
In the case of the following code, should @food.cheese return the string value "%int(@calories * 0.33)" or the integer value '333'? In 3.17, I had always expected the results to be an integer value; Though recent testing makes me wonder if that was a bug.

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <class name="Test" copy="yes">
    <var name="calories" copy="yes">1000</var>
    <alias name="test" copy="yes">
      <value>#print @food.cherry_pie
#print @food.cheese</value>
    </alias>
    <var name="food" type="Record" copy="yes">
      <value>cheese=%int(@calories * 0.33)|dessert=1|cherry_pie=%int(@calories*3/4)|utensil=fork|entrees=one,two</value>
      <json>{"dessert":1,"cherry_pie":"%int(@calories*3\/4)","utensil":"fork","entrees":"one,two","cheese":"%int(@calories * 0.33)"}</json>
    </var>
  </class>
</cmud>
Reply with quote
Zugg
MASTER


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

PostPosted: Tue Jun 15, 2010 5:02 pm   
 
It should return a String value, not a number. Variable expansion in CMUD (unlike zMUD) is not recursive. So the function should not getting evaluated unless you use %eval on the result.

My guess is that the code which handles user-defined functions was messed up with the previous string list and database variables and might have been treating a string value as a user-defined function, which isn't allowed within a string list or database variable.

However, your report *does* indicate a problem/bug with the import of json XML. When I import your above variable, the underlying json table isn't correct, so I've added that to the bug list.
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