mIRC Home    About    Download    Register    News    Help

Print Thread
Trying to echo a literal # char #50084 18/09/03 03:46 PM
Joined: Sep 2003
Posts: 7
S
Sahasrahla Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Sep 2003
Posts: 7
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?

Re: Trying to echo a literal # char #50085 18/09/03 03:47 PM
Joined: Jun 2003
Posts: 242
R
r0ck0 Offline
Fjord artisan
Offline
Fjord artisan
R
Joined: Jun 2003
Posts: 242
echo $+($chr(35),%x)

Re: Trying to echo a literal # char #50086 18/09/03 04:03 PM
Joined: Sep 2003
Posts: 7
S
Sahasrahla Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Sep 2003
Posts: 7
Thank you! That worked wonderfully...

Re: Trying to echo a literal # char #50087 18/09/03 04:04 PM
Joined: Jun 2003
Posts: 242
R
r0ck0 Offline
Fjord artisan
Offline
Fjord artisan
R
Joined: Jun 2003
Posts: 242
mp smile

Re: Trying to echo a literal # char #50088 18/09/03 11:03 PM
Joined: Feb 2003
Posts: 810
C
cold Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 810
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()".


* cold edits his posts 24/7
Re: Trying to echo a literal # char #50089 18/09/03 11:15 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
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 }.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Re: Trying to echo a literal # char #50090 19/09/03 12:13 AM
Joined: Feb 2003
Posts: 810
C
cold Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 810
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.


* cold edits his posts 24/7
Re: Trying to echo a literal # char #50091 19/09/03 03:13 AM
Joined: May 2003
Posts: 161
A
Ashkrynt Offline
Vogon poet
Offline
Vogon poet
A
Joined: May 2003
Posts: 161
$(#,0) is a little bit faster than $chr(35) actually

You could save even another character by using a null second parameter: $(#,) :tongue:

Re: Trying to echo a literal # char #50092 19/09/03 10:19 AM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
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:


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com