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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Aerious
Wanderer


Joined: 21 Jan 2008
Posts: 62

PostPosted: Mon Jan 21, 2008 5:44 pm   

script generated string output strange
 
Having trouble getting output right on a little timer reporting script I was writing... it is behaving abnormally, and worked in past zmud (though I since changed it to be cmud friendly w/ the variables)

Code:

pmsg = ""
#if (%db(@prots,"greater")) {#add pmsg "%db(@prots,greater) %eval(@timer-%db(@prots,"greater_start")) s~~(%db(@prots,"greater_history") s~~) | "} {#add pmsg "%db(@prots,"greater_name") DOWN | "}
#if (%db(@prots,"lesser")) {#add pmsg "%db(@prots,lesser). %eval(@timer-%db(@prots,"lesser_start")) s~~(%db(@prots,"lesser_history") s~~) | "} {#add pmsg "%db(@prots,"lesser_name") DOWN | "}
#if (%db(@prots,iw)) {#add pmsg "IW %eval(@timer - %db(@prots,"iw_start")) s | "} {#add pmsg "@prots.iw_name DOWN | "}
party say @pmsg



outputs ->
Quote:
party say PFG132s(500s)| lPhys. 0 s(875 s) | IW 0 s |


now, if you look at the spacing between the 'greater' and 'lesser' prots, it is identicle, the only difference being the '.' put in the 'lesser' line.

I used the . because I saw somewhere it was to 'append' a string. so i was not expecting the dot to show up after Lphys

stranger even then, is since the dot is there, magically all the spacing works as it should.

I tried adding just a " " (as shown) where the . is instead, but it then caused the output to break completely, as follows:

Quote:
party say PFGlPhys. 0 s(875 s) | IW 0 s |




I'm totally unsure what I am doing wrong, but as said, very very similar syntax worked in zmud just fine. all i changed from there to here is the %db(db,key) to used a key'd list's values.

Any help would be welcomed.

Goal: allow formatting to show manufactured message as intended. (without the '.' after lphys, etc)

Thanks,
Aerious

PS. I use cmud 2.18
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Mon Jan 21, 2008 9:57 pm   
 
I think the problem is coming from the nested quotes. I know #ADD can be used for string concatenation, but I would never recommend it, use %concat instead.
Code:
#if (%db(@prots,"greater")) {pmsg=%concat(@pmsg," ",%db(@prots,"greater")," ",%eval(@timer-%db(@prots,"greater_start"))," s(",%db(@prots,"greater_history")," s) | ")} {pmsg=%concat(@pmsg,%db(@prots,"greater_name")," DOWN | ")}

_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Aerious
Wanderer


Joined: 21 Jan 2008
Posts: 62

PostPosted: Wed Jan 23, 2008 1:50 pm   
 
Thank you Vijilante, it worked like a charm.

I guess I was using #ADD back from zmud days, and zmud did not care so much about the "" or something.

However %concat works great.

Thanks
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion 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