|
Caled Sorcerer
Joined: 21 Oct 2000 Posts: 821 Location: Australia
|
Posted: 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 |
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: 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." |
|
|
|
Caled Sorcerer
Joined: 21 Oct 2000 Posts: 821 Location: Australia
|
Posted: 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 |
|
_________________ Athlon 64 3200+
Win XP Pro x64 |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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.
|
|
|
|
Caled Sorcerer
Joined: 21 Oct 2000 Posts: 821 Location: Australia
|
Posted: 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 |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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.
|
|
|
|
|
|