Entox|cated Posted July 1, 2007 Report Share Posted July 1, 2007 ok i'm having a bit of troulbe authing using bvars on sparkpea.. if i do on *:sockread:?#*:{ var %x = "" sockread -f %x tokenize 32 %x if ($1-3 = AUTH GateKeeperPassport S) { } etc... } it works fine, but if i do on *:sockread:?#*:{ sockread -n &x if ($gettok($bvar(&x,1-).text,1-3,32) = AUTH GateKeeperPassport S) { } etc... } i get an error.. * Invalid parameters: $bvar (line 66, connection.mrc) if anyone can help me out would be great thanks. =) Link to comment Share on other sites More sharing options...
The Gate Keeper Posted July 1, 2007 Report Share Posted July 1, 2007 well for one thing, you are forgetting that the sockets send blank lines as well, as terminals. So you need to compensate for that as well. on *:sockread:?#*:{ sockread -n &x if ($bvar(&x,0) > 0) { if ($gettok($bvar(&x,1-).text,1-3,32) = AUTH GateKeeperPassport S) { } etc... } } I believe that's the only problem. You could use a tockenizer so save you from doing $gettok for everything. So the above code becomes... on *:sockread:?#*:{ sockread -n &x if ($bvar(&x,0) > 0) { tokenize 32 $bvar(&x,1-).text if ($1-3 = AUTH GateKeeperPassport S) { } etc... } } Basically, you can specify a range ($1-3) to give you a defined from-to comparison. You could also do something like $1 $2 $3 =... I know it's a bit scrutinising, but i would also recommend following mIRC's structure and doing the "if statement" correct. You are doing a comparison using 1 "=" sign. With mIRC you should use 2 or 3 "=" characters. Please refer to the mIRC help file under "if then else" for correct syntax. This is just good programming practice if you want to better your knowledge in programming. Link to comment Share on other sites More sharing options...
hixxy Posted July 1, 2007 Report Share Posted July 1, 2007 Perhaps the line doesn't end in a CRLF, which would cause no bytes to be read into &x. Try using sockread -fn instead. What The Gate Keeper recommended should stop the error, but it might mean that you miss data. TGK: Fyi, you could use $sockbr there instead of $bvar(&x,0) Link to comment Share on other sites More sharing options...
The Gate Keeper Posted July 1, 2007 Report Share Posted July 1, 2007 yea, i remembered the other method as well. I pretty much just copied/pasted from my script, as i wasn't bothered to work it out. Thanks for the pointer. Link to comment Share on other sites More sharing options...
Guest Spuny Posted July 2, 2007 Report Share Posted July 2, 2007 on *:sockread:?#*: { sockread -n &x if ($regex($bvar(&x,1,$bvar(&x,0)).text,/AUTH GateKeeperPassport S/)) {} } Link to comment Share on other sites More sharing options...
Entox|cated Posted July 2, 2007 Author Report Share Posted July 2, 2007 hay thanks for the replys everyone after a while i figured it out, like TGK said i forgot about it setting blank lines .. it was like 2 am in the morning and hadn't had my coffee boost. ;p thanks again Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now