mIRC Home    About    Download    Register    News    Help

Print Thread
#7761 22/01/03 06:48 AM
Joined: Jan 2003
Posts: 24
C
Codeq Offline OP
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Jan 2003
Posts: 24
hi.. cant sleep ;p

2 things i hate most on mirc scripting.

1st is, that it sometimes doenst recognize i want a var used as an interger and not as a string. for example $gettok(%foo,%i,32) .. sometimes i need to enclose %i into a $calc() to avoid an invalid parameter error ..

2nd one is. in some cases its easier to interleave some identifers wich use comma chr(44) seperatet params. for example $gettok(%foo,$rand(1,99),32) doesnt work. it sais inavilid format..
would be great if the parser could know which chr(44) belongs to which identifer at least the mirc own identifers. on my own srcipted identifers i always use chr(32), because ive no problems interleaving them.


--
Codeq (J. Diel)
euIRCnet LocOp (irc.hes.de.euirc.net)
http://coding-board.de | www.euirc.net
#7762 22/01/03 07:12 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
1) "sometimes"? What are you talking about? $gettok(%var1,%var2,32) always works, provided that %var2 is a number.

2) Again, what are you talking about?
//var %foo = one two three | echo -s $gettok(%foo,$rand(1,3),32)
Execute that command as many times as you like... it will never error.

Both your problems sound like an error on your part. Maybe if you posted a sample code that fails always we could sort it out.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#7763 22/01/03 07:22 AM
Joined: Jan 2003
Posts: 24
C
Codeq Offline OP
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Jan 2003
Posts: 24
urks... k.. the $gettok and $rand example were bad ones.. those work...
ill look around my scripts.. i had it serveral times...

to 1.
if im juggling with numbers and using them as strings, and afterwards as numbers again, than mirc sometimes get dizzy ... it sais definitively invalid params. and its all solved with an $calc() around. i make a lot math stuff with mirc, because mirc can handle with ints and chars so easily. no typecasts needed. but that phenomenon is no failure within my scripts.

and for the second one im lookin for and concrete example... but i gotta sleep now ;/ ..need to post it tomorrow..


edit: one thing... it only happens on large scripts.. where i use a lot of vars ... around 300 %vars and about 800 identifers.. maybe it has sth to with that.
that its caused by a bug i cant believe (but how knows wink ), because that script runs about one year without touhing it, and its handling a userdatabase with 1200 people and has got 2 permanent connections to an sql DB. its an user agent that never failt since that time. and a bug cant be solved by putting a $calc() around.... than there must be a chr within that var anytime. and the debug window is empty..

Last edited by Codeq; 22/01/03 07:45 AM.

--
Codeq (J. Diel)
euIRCnet LocOp (irc.hes.de.euirc.net)
http://coding-board.de | www.euirc.net
#7764 23/01/03 03:32 AM
Joined: Dec 2002
Posts: 66
Babel fish
Offline
Babel fish
Joined: Dec 2002
Posts: 66
Even using $calc() the returned value isn't a number (I don't think). I believe everything is a string, atleast all scripts are that way.

mIRC don't support literal strings and real numbers afaik.


- Linux System Administrator, Darktides Communications, LLC.
#7765 23/01/03 07:34 AM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
Correct. mIRC does its own typecasting internally. Everything is a string; nothing is stored as an int or double or whatnot. $calc(5 + 0.5bleh) returns 5.5, whereas $calc(5 + bleh0.5) returns 5. From this, we can safely conclude that not only does mIRC do its own typecasting, it also does a little error checking on the strings involved. This is quite handy to strip off trailing characters, such as when you're getting rid of the hrs on 4hrs.


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#7766 24/01/03 07:59 AM
Joined: Jan 2003
Posts: 24
C
Codeq Offline OP
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Jan 2003
Posts: 24
hmmm is it possible that the error checking called by some functions is workin wrong? or that the error checking is a bit too slow to return that there is sth to use into a var? because i cant explain it why i works for me like i described.
but good to know that the typcast is done while executing the command not while parsing.


--
Codeq (J. Diel)
euIRCnet LocOp (irc.hes.de.euirc.net)
http://coding-board.de | www.euirc.net
#7767 24/01/03 10:51 PM
Joined: Dec 2002
Posts: 25
S
Ameglian cow
Offline
Ameglian cow
S
Joined: Dec 2002
Posts: 25
You can't do typecasting at parse time with a language like mIRC's, it's type juggling, and it's done at execution time since there is no other way really smile

Personally I think the whole way it works is rather uggly :P

Last edited by SubSpace; 24/01/03 10:52 PM.

Link Copied to Clipboard