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
Caled
Sorcerer


Joined: 21 Oct 2000
Posts: 821
Location: Australia

PostPosted: Wed Jun 11, 2008 4:52 pm   

[226] Is is possible to pass spaces as part of string arguments to a function?
 
<func name="setcl" id="1528">
<value>$a=0
#SH $x
$a=$y
#RETURN $a
<arglist>$x,$y</arglist>
</func>

I stripped down the function I am attempting to create, so the above looks contrived.


#SH @setcl(this is x,this is y)

Displays:

thisisx
thisisy

I'd really like the spaces to be preserved, but am not sure if this is possible.
_________________
Athlon 64 3200+
Win XP Pro x64
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Wed Jun 11, 2008 4:56 pm   
 
Have you tried using quotes?

Code:
#SH @setcl("this is x","this is y")
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
Caled
Sorcerer


Joined: 21 Oct 2000
Posts: 821
Location: Australia

PostPosted: Wed Jun 11, 2008 5:04 pm   
 
Seems so obvious. I had not, though I see now I should have. Quotes are always the answer to wanting to keep spaces.

Something I don't understand is why we should ever need to though. I've been mudding for a fair while now, and I don't recall ever wanting to strip spaces from any situation. At least, no situation where I have not had %replace, %trim etc as an option. Seems counter-intuitive to me.

Still, thanks for the heads-up on that, it worked Embarassed
_________________
Athlon 64 3200+
Win XP Pro x64
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Wed Jun 11, 2008 5:34 pm   
 
It's stripping the spaces because your syntax is dodgy, but not quite invalid. It's not really a bug because it's a good practice to surround your strings with "" in practically any situation.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Caled
Sorcerer


Joined: 21 Oct 2000
Posts: 821
Location: Australia

PostPosted: Thu Jun 12, 2008 1:10 am   
 
Sorry to bring this up again, but are you saying my syntax was dodgy because I didn't put the quotes (which I can accept and start getting into the habit of always doing) or is there something else wrong with my syntax as well?
_________________
Athlon 64 3200+
Win XP Pro x64
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Jun 12, 2008 1:13 am   
 
The former. Not having the quotes isn't really wrong, because in most situations it's obvious what you meant, but there're fringe cases (especially when you have a space between the comma and the second parameter) where you're not sure exactly what's part of the argument and what's not. Hence the confusion.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
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