mIRC Home    About    Download    Register    News    Help

Print Thread
Simplification not working #235583 28/12/11 06:55 AM
Joined: Nov 2009
Posts: 295
P
pball Offline OP
Fjord artisan
OP Offline
Fjord artisan
P
Joined: Nov 2009
Posts: 295
I have a variable with three sets of rgb values tokenized with spaces and I'd like to get the $rgb() value for 1-3, 4-6, and 7-9. I tried to do a simple and short method but it isn't working for me so I'm stuck with a longer method.

; long version that works, three separate gettoks
$rgb($gettok(%clockcolors,1,32),$gettok(%clockcolors,2,32),$gettok(%clockcolors,3,32))

; short version that doesn't????
$rgb($replace($gettok(%clockcolors,1-3,32),$chr(32),$chr(44)))

I'm just perplexed at why the second doesn't work. The $replace() yields 0,197,255 which works when manually pasted into $rgb(), but it doesn't work in scripted form


http://scripting.pball.win
My personal site with some scripts I've released.
Re: Simplification not working [Re: pball] #235584 28/12/11 10:03 AM
Joined: Dec 2002
Posts: 3,138
C
Collective Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
Your second example doesn't work for the same reason using $chr(44) in $replace works fine. Identifiers take parameters separated by literal commas, and each parameter is evaluated individually. It's the reason $+(a,$chr(44),b) is not the same as $+(a,,,b).

Another example that won't work: //var %t = 200,100,50 | echo -a $rgb(%t)

But you can use the [ ] evaluation brackets to get around this:
//var %t = 200,100,50 | echo -a $rgb( [ %t ] )

This way the variable is evaluated before the parameters are split up, so the commas it contains are taken literally.

Re: Simplification not working [Re: Collective] #235585 28/12/11 05:10 PM
Joined: Nov 2009
Posts: 295
P
pball Offline OP
Fjord artisan
OP Offline
Fjord artisan
P
Joined: Nov 2009
Posts: 295
ok I though it might be something related to evaluation and such. but putting $eval around the $replace doesn't work either. Thanks for point out using [] to make it work, I've never used [] nor do I really care for them but they make this work so I'm happy.


http://scripting.pball.win
My personal site with some scripts I've released.