Skip to content
Sparkpea Chat Network

$bvars Help Anyone?

A TG007 community discussion started by Entox|cated.

Discussion 6 posts
Page 1 of 1
Open
Topic #8650 · 6 published posts · 3,707 views

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. =)

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.

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)

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.

on *:sockread:?#*: {

sockread -n &x

if ($regex($bvar(&x,1,$bvar(&x,0)).text,/AUTH GateKeeperPassport S/)) {}

}

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 :)