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


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Sep 23, 2010 1:44 am   

[3.29] (BUG) Record Variables breaking %format
 
Code:

<alias name="test_format" id="1651">
  <value>#show "Test format"
$test1="This is test 1"
$val1=31
#LOCAL $val2
#ADDKEY $val2 val_a 30
#ADDKEY $val2 val_b 31
$test1=%format(&amp;-$val1 s, $test1)
#show $test1"|"
$test1="This is test 1"
$test1=%format($-$val2.val_b s, $test1)
#show $test1"|"</value>
</alias>


Worked in previous versions. Now no longer works as of 3.29. Unsure of how changing for pattern matching might have affected it, but it's definitely broken in 3.29 when it worked in 3.28.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Zugg
MASTER


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

PostPosted: Thu Sep 23, 2010 3:16 am   
 
Sorry, but I can't even figure out what you are trying to do here. The argument for %format needs to be a string. You MUST enclose the first argument in " quotes. I have no idea how this would have worked previously or how you would have even expected it to work. But you need to be more careful to enclose strings in " quotes, especially when they contain spaces and other special characters.

Using:

$test1=%format(%concat("&-", $val1, " s"), $test1)
$test1=%format(%concat("$-", $val2.val,"_b s", $test1)

is the way it should work.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Sep 23, 2010 3:21 am   
 
I actually never knew that, I'll try that then.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Sep 23, 2010 3:28 am   
 
Hmm, this is the specific syntax in which I found the error:

Code:

    $spell=%format( %concat("&-", @afw_set.max_len, " s"), $spell)
    $sval=%format( %concat("&", @afw_set.num_len, " s"), $sval)


in my own script. As you can see, I've changed it now, but the same problem occurs as before in that it's not formatting and refusing to show what I'm trying to format. Using a local variable works, even without making it a string, but this method does not seem to be working, what am I doing wrong?
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Zugg
MASTER


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

PostPosted: Thu Sep 23, 2010 3:29 am   
 
You need to show me the values of your @afw_set variable for me to test this.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Sep 23, 2010 3:31 am   
 
Code:

  <var name="afw_set" type="Record" id="49">
    <value>history=1|top=0|spl=2|max_len=18|num_len=2|blink=0</value>
    <json>{"history":1,"top":0,"spl":2,"max_len":18,"num_len":2,"blink":0}</json>
  </var>
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Zugg
MASTER


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

PostPosted: Thu Sep 23, 2010 4:21 pm   
 
Confirmed problem and added to bug list. The parser isn't expanding the @db.key in the function arguments for some reason.
Reply with quote
Zugg
MASTER


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

PostPosted: Thu Sep 23, 2010 5:29 pm   
 
Actually, it had nothing to do with the @db.key issue. The problem in your above script is that you have a space before the "s" character. Your format statement ends up looking like:

%format( "&-18 s"), $spell)

when the record is expanded. Notice the space between the 18 and the s. That is an invalid format syntax. Get rid of this extra space and then it works fine.
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