mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2006
Posts: 166
B
b1ink Offline OP
Vogon poet
OP Offline
Vogon poet
B
Joined: Oct 2006
Posts: 166
If I didn't call /tokenize and tried to //echo -a $* it doesn't return any error msg.

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
This isn't a bug. /command $* is run $0 times: if $0 is zero (meaning /tokenize wasn't used or parameters weren't passed etc), /command will be run zero times, so nothing happens. This isn't an error though, so no error message should be displayed. If you want to see whether there are $N's, just check $0:
Code:
if ($0) scid -r yourcommand $*
else do-something-else


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Oct 2006
Posts: 166
B
b1ink Offline OP
Vogon poet
OP Offline
Vogon poet
B
Joined: Oct 2006
Posts: 166
is it possible to check if ($*) ? because I want to pass it in an identifier with many parameters.


Kind Regards, blink
Joined: Feb 2006
Posts: 546
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
you can't directly include $* in constructs like if/while or identifiers, but what qwerty implied with /scid -r was that you could form an escaped command including $*, then use the fact that /scid re-evaluates its command:

Code:
//tokenize 32 a b c 0 d | scid -r if ( $* ) echo -a $!v1


this tends to get messy, and you also need to be careful as always when passing arbitrary data to things like /scid as all your $N tokens will be evaluated as code.. but if you know what you're doing it can be handy :>


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Joined: Oct 2006
Posts: 166
B
b1ink Offline OP
Vogon poet
OP Offline
Vogon poet
B
Joined: Oct 2006
Posts: 166
From the beginning I thought there is a way to check if ($*) ain't null without passing it /scon. because I want to use some script in an identifier. whatever.

thanks both of ya


Kind Regards, blink
Joined: Feb 2006
Posts: 546
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
then why don't you use what qwerty showed? if $0 is non-0 then parameters have been passed.

but if you also want to check against things like $youridentifier(,,) where $0 is 3 but each $N is null you could check

Code:
if ($len($1-) >= $0) && ($0) {


which forces there to be at least one non-$null parameter


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
Like you said that would still make $* trigger on null values
here a tighter workaround
[code]
alias blink {
var %n = $regsubex($str(a,$0),/(.)/g,$+($!len($\n),$chr(32)))
if (0 !isin $(%n,2)) && ($0) echo -a $*
}
[code]

Doesn't matter how many parameters you specify as long as they are all not $null.
Well "doesn't matter" taken into account $len($N)<space> which is 9 characters long you should reconcider doing it another way if $0 is going to be over 94 ;P
//noop $blink( [ $gettok($str($+($!r(a,z),$chr(44)),94),1-,44) ] )
highest ammount of parameters you can send with this.


$maybe
Joined: Oct 2006
Posts: 166
B
b1ink Offline OP
Vogon poet
OP Offline
Vogon poet
B
Joined: Oct 2006
Posts: 166
Never thought $* could be called without /tokenize. Its ok. I'll use another method for the code I'm working on. thanks mpd.

Last edited by b1ink; 02/12/06 04:29 PM.

Kind Regards, blink
Joined: Feb 2006
Posts: 546
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
if 94 is an unreasonable limit (lol laugh) you could take advantage of error handling:

Code:
alias blink {
  bset -t &amp;blink 1 $*
  ; code
  return
  :error
  reseterror
  ; null parameter exists
}


edit: then theres that bug with using $* twice in the same routine :P oh well, could always retokenize but kinda defeats the purpose.. :S


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Joined: Oct 2006
Posts: 166
B
b1ink Offline OP
Vogon poet
OP Offline
Vogon poet
B
Joined: Oct 2006
Posts: 166
I already submitted the code on mirc.net and just waiting for approval. grin


Kind Regards, blink
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
This one supports more tokens (173) but uses $lf as separator, which is uglier:
Code:
alias blink {
  var %n = $regsubex($str($+($,a,$lf,$chr(44)),$0),/a/g,\n)
  if $0 &amp;&amp; $count($($!+( %n ),2),$lf) == $0 { echo -a $* }
}
Based on the fact that if $N is $null, $N<anything> becomes $null too (and assuming no $lf is in the params).

Btw, you need $istok() instead of isin (for cases like $len($5) = 10).


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
doh :tongue:


$maybe

Link Copied to Clipboard