mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2008
Posts: 95
A
Babel fish
OP Offline
Babel fish
A
Joined: Dec 2008
Posts: 95
To avoid looping through $gettok(), I remembered the ability to use $* after tokenizing something:

Code:
tokenize 32 . ! -
say $*


This works well and results in:

Quote:
<me> .
<me> !
<me> -




Now I want to put a word at the end of each message:

Code:
tokenize 32 . ! -
say $* word


This also works well so far and results in:

Quote:
<me> . word
<me> ! word
<me> - word




But I want to have the word right after the character without the space inbetween:

Code:
tokenize 32 . ! -
say $* $+ word


Now this is the part that fails and results in:

Quote:
<me> .
<me> !
<me> -




Now I do realize that $* is not even part of the help file, probably for several valid reasons,
but is there a way to make this above work the tokenize/$* way?

Thanks!

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Here is what you should do:
Code:
  tokenize 32 . ! -
  scid -r msg # $* $!+ word

Joined: Dec 2008
Posts: 95
A
Babel fish
OP Offline
Babel fish
A
Joined: Dec 2008
Posts: 95
Hi,

well that's quite tricky, nice, thanks.

Joined: Jul 2006
Posts: 4,150
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,150
Be careful, here #, which is $chan will be evaluated twice, not really safe.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Then what do you suggest to make it safe at this point? By using a safe alias involving the encode and decode?

Joined: Jul 2006
Posts: 4,150
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,150
yes, $regsubex can also be used :
Code:
alias safe bset -ct &a 1 $1 | return $!regsubex(safe, $bvar(&a,1-) ,/(\d+)(?: |$)/g,$chr(\1))


tokenize 32 . ! -
scid -r msg $safe(#) $* $!+ word

for any parameters that you don't know for sure what it can be, use the $safe alias


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Dec 2008
Posts: 95
A
Babel fish
OP Offline
Babel fish
A
Joined: Dec 2008
Posts: 95
Hmm, how can it be dangerous if # or $chan is evaluated twice?
I can't see the problem as long as actual channelnames can't have a $ prefix.
And wouldn't $!chan be sufficient?

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
#$identifier gets evaluated. Compare:
/join #$me
/timer 1 1 join #$me

Of use e.g. for /join #$$?="name of channel?"
(to work regardless of a leading #-char in the user's input)

Joined: Dec 2008
Posts: 95
A
Babel fish
OP Offline
Babel fish
A
Joined: Dec 2008
Posts: 95
Ahhh, right, I remember that from the default mIRC aliases, thank you.


Link Copied to Clipboard