Jump to content

$bvars Help Anyone?


Recommended Posts

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...