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
wrym
Magician


Joined: 06 Jul 2007
Posts: 349
Location: The big palace, My own lil world

PostPosted: Wed Jun 16, 2010 12:35 pm   

3.19e eating | character
 
The following bit of code worked in 3.17, and 3.18d but fails in 3.19e, if i escape the | character with ~ it does work, which wouldn't be entirely unreasonable

expected result is adding/updating 2 db record keys, test and beta, instead the | character is geting ate back on the first like asigining value to $addkeystring.

Code:
  <var name="test" type="Record" id="1">
    <value>0|test="123beta=32"</value>
    <json>{"0":"","test":{"123beta":"32"}}</json>
  </var>
  <alias name="test" id="2">
  <value>#print @test
#local $val1 $val2 $val3
$val1 = 123
$val3 = 321
$addkeystring =%if($val1,test=$val1|)%if($val2,testb=$val2|)%if($val3,beta=$val3|)
#print $addkeystring
$addkeystring = %leftback($addkeystring,1)
#print $addkeystring
#addkey test $addkeystring
#print @test</value>
</alias>
_________________
"To the engineer, all matter in the universe can be placed into one of two categories: (1) things that need to be fixed, and (2) things that will need to be fixed after you've had a few minutes to play with them" - Scott Adams, The Dilbert Principle
Reply with quote
Zugg
MASTER


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

PostPosted: Wed Jun 16, 2010 4:47 pm   
 
This is the line that is wrong and very confusing:
Code:
$addkeystring =%if($val1,test=$val1|)%if($val2,testb=$val2|)%if($val3,beta=$val3|)

What syntax is this? What are you trying to do here? My guess is that you are getting carried away with implicit concat. But maybe you can better explain this line. My guess is that you probably want something more like this:
Code:
$addkeystring = %concat( %if($val1,test=%concat($val1,"|")), %if($val2,testb=%concat($val2,"|")), %if($val3,beta=%concat($val3,"|"))

But I think it might be time for you to step back a bit and find out what you are really trying to accomplish and start using the normal list commands and functions rather than trying to construct some sort of string list on the fly using | characters. It will make your script more readable, supportable, and faster, but it's hard to take this out of context of the rest of your script.

In any case, I'm certainly not going to worry about backwards compatibility with that specific line. There are just too many problems with it. It's more like zMUD code than how you are supposed to write it in CMUD. Don't take offense, just trying to help you write better CMUD scripts.

No matter what you do, the | in the above line need to be put inside " quotes to treat it as a literal character, like

test=$val"|"

but that's still a pretty ugly implicit concat.
Reply with quote
wrym
Magician


Joined: 06 Jul 2007
Posts: 349
Location: The big palace, My own lil world

PostPosted: Wed Jun 16, 2010 4:59 pm   
 
Yeah, it's deffinatly a little odd.

It's part of my prompt trigger which has slowly grown from a handful of values to now more than 20, I got tired of managing 20 different variables and started putting them as a db record. In my latest rewrite I spent a fair bit of time doing some benchmarking, and ended up taking 2 approaches, most commonly changing variables I did put as separate variables, but most of the others which only change every 2-3 dozen lines or more I put into dbrecord. even at that #addkey with 15-20 variables takes several times longer than #addkey with one or two values. It ended up being faster to stack the %if's and only #addkey a few values instead of a whole bunch.
_________________
"To the engineer, all matter in the universe can be placed into one of two categories: (1) things that need to be fixed, and (2) things that will need to be fixed after you've had a few minutes to play with them" - Scott Adams, The Dilbert Principle
Reply with quote
Zugg
MASTER


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

PostPosted: Wed Jun 16, 2010 7:26 pm   
 
You'll want to re-do all of your benchmarks because of the significant changes to string lists and db variables in the latest beta version. #addkey should no longer have a problem with variables that have a lot of keys.
Reply with quote
wrym
Magician


Joined: 06 Jul 2007
Posts: 349
Location: The big palace, My own lil world

PostPosted: Wed Jun 16, 2010 7:43 pm   
 
Yeah, I was planning on it, your initial benchmarks were rather impressive.

Speaking of performance, I know this was briefly talked about in another post, but since I happen to run 8 gauges off of these values, has the code that deals with updating gauges been affected by this?
_________________
"To the engineer, all matter in the universe can be placed into one of two categories: (1) things that need to be fixed, and (2) things that will need to be fixed after you've had a few minutes to play with them" - Scott Adams, The Dilbert Principle
Reply with quote
Zugg
MASTER


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

PostPosted: Wed Jun 16, 2010 10:11 pm   
 
No change to how buttons are updated. You need to use a separate variable for each button still. At some point in the future I might figure out a way to optimize this for database variables, but not for the public version.

The issue is that when the button is compiled, it generates a list of variables that the button depends upon. When that variable is updated, the button is refreshed. All of this code runs at a high level dealing with generic "variables" and has no knowledge of the underlying variable structure (like table, list, etc). Specifying a table key, like @varname.key doesn't actually point to a "variable" anymore...it points to a low-level table structure value. And this json table structure has no way to notify a button when just the specific key value is changed.
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