mIRC Home    About    Download    Register    News    Help

Print Thread
#35067 08/07/03 09:12 PM
Joined: Feb 2003
Posts: 282
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Feb 2003
Posts: 282
Hi to ya all.

In one of the scripts that I'm writting, I want to take the 1 token before the last one, for example:

Hello to ya all.

I want to put the "ya" inside a varible

I'm using Tokenize 32 command to get the $1 $2 ..., so this is that I'm doing:

%before = $ $+ $calc($0 - 1)

But then I gust get $3 and not "ya"

If I write:
%pack.size = [ $ $+ $calc($0 - 1) ]
I get 3.

I don't want to use $gettok. Can someone explain me how to use the evaluation brackets?? I never unverstand what their purpose is.
confused

#35068 08/07/03 09:23 PM
Joined: Dec 2002
Posts: 349
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Dec 2002
Posts: 349
$eval($ $+ $calc($0 - 1),2) should work. I prefer to use $eval() instead of the [ ] brackets, I feel it makes things easier to read. If you want to use [ ] though i think it is [ [ $ $+ $calc($0 - 1) ] ] (depth of ['s is the same as the N parameter in $eval(text,N)). I'm not sure which will be faster, someone has probably benchmarked it.

Hope that helps. smile

#35069 08/07/03 09:30 PM
Joined: Feb 2003
Posts: 282
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Feb 2003
Posts: 282
Ok, I think it is working.

Thanks smile

Last edited by saragani; 08/07/03 09:43 PM.
#35070 09/07/03 01:15 AM
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
Actually, I benchmarked [ [ ] ] vs $eval(,2) a while back, and found brackes to be 33% faster than $eval. I believe others have said 13%... I just wish Khaled added a /bench command. smile

- Raccoon


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
#35071 09/07/03 11:05 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Actually, [ [ $ $+ $calc($0 - 1) ] ] won't work. When a pattern like "[ <foo> $+ <bar> ]" is used, only <foo> is evaluated before $+ concatenates <foo> and <bar>. So, "[ $me $+ $bits ]" would evaluated to "qwerty$bits", not to "qwerty32". To force the evaluation of the element to the right of $+, you need an extra [ ] pair around it. Regarding the original question, you'd have to use either this:
[ $+ [ $calc($0 - 1) ] ]
or this:
[ [ $+($,$calc($0 - 1)) ] ]


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#35072 09/07/03 11:24 AM
Joined: Dec 2002
Posts: 349
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Dec 2002
Posts: 349
Thanks for the pointer, I thought mIRC would 'jump ahead' to the closing ] before evaluating :P


Link Copied to Clipboard