mIRC Homepage
Posted By: Sahasrahla Trying to echo a literal # char - 18/09/03 03:46 PM
I feel kinda silly, cuz this has been the most troublesome thing I've run into so far, but I'm trying to echo a # followed by a variable. I tried "echo # $+ %x" but that resulted in
#chan22 (where "#chan" is the channel I'm on and "22" is what's in the variable...)

Also tried escaping the # with a \, but that didn't work either.

Any suggestions?
Posted By: r0ck0 Re: Trying to echo a literal # char - 18/09/03 03:47 PM
echo $+($chr(35),%x)
Posted By: Sahasrahla Re: Trying to echo a literal # char - 18/09/03 04:03 PM
Thank you! That worked wonderfully...
Posted By: r0ck0 Re: Trying to echo a literal # char - 18/09/03 04:04 PM
mp smile
Posted By: cold Re: Trying to echo a literal # char - 18/09/03 11:03 PM
You could also use "$(#)", which is smaller (and easier to read IMO); plus, this works with '{', '|' and '}' as well.
In case you don't know, "$()" is the same as "$eval()".
Posted By: qwerty Re: Trying to echo a literal # char - 18/09/03 11:15 PM
That would be $(#,0). It's still shorter than $chr(35) by two chars, although I suspect a tiny bit slower too.

Also, $() doesn't work with { or } when they're alone. For some reason, $({) and $(}) return "0 0". Generally, preventing mirc from treating | as a special char is easier than with { or }.
Posted By: cold Re: Trying to echo a literal # char - 19/09/03 12:13 AM
Oops, that's me and my disadvantage of still using 5.91 and assuming it's the same way nowadays. $() must have been bugged or something, because it "works" here.
Posted By: Ashkrynt Re: Trying to echo a literal # char - 19/09/03 03:13 AM
$(#,0) is a little bit faster than $chr(35) actually

You could save even another character by using a null second parameter: $(#,) :tongue:
Posted By: qwerty Re: Trying to echo a literal # char - 19/09/03 10:19 AM
I just benchmarked it and you're right. The difference is really really small (it took a 30000-iteration loop for a 'steady' difference of 10 msecs to emerge), but $(#,0) is faster indeed.

I like the $(#,) too :tongue:
© mIRC Discussion Forums