mIRC Home    About    Download    Register    News    Help

Print Thread
#28739 08/06/03 09:26 PM
Joined: Jun 2003
Posts: 7
S
Seigre Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Jun 2003
Posts: 7
Hey, long time no see laugh! and I need your help again guys. I suck at scripting, but I'm learning.

What I was wondering was is there any way for mIRC to tell me what variable has the greatest value, and what has the greatest value beginning with %x

I've tried a lot of things, but come up empty handed.

Oh! If anyone has any advice on learning about sockets too I'd really appriciate it! Thanks again guys, you rock.

#28740 08/06/03 11:05 PM
Joined: Mar 2003
Posts: 63
N
Babel fish
Offline
Babel fish
N
Joined: Mar 2003
Posts: 63
You can try this in order to find the biggest variable begining by %x :
Code:
alias find.max.var {
  var %i = 1
  var %MAX = $var(%x*,0)
  var %found = $var(%x*,%i)
  while (%i <= %MAX) {
    var %tmp1 = $var(%x*,%i)
    inc %i
    var %tmp2 = $var(%x*,%i)
    if %tmp1 < %tmp2 { var %found = %tmp2 }
  }
  return %found
}
 


Replace the %x* by %* if you want to know the biggest variable between all of them.
Hope that's what you wanted smile

#28741 08/06/03 11:26 PM
Joined: Jun 2003
Posts: 7
S
Seigre Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Jun 2003
Posts: 7
And here I was thinking it was impossible..

Thank you so much grin

#28742 09/06/03 02:24 AM
Joined: Jun 2003
Posts: 7
S
Seigre Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Jun 2003
Posts: 7
One problem...

Code:
 var %tmp1 = $var(%x*,%i) 


I've figure out that %tmp1 now will have the value of something like "%xa" and not %xa's own value (ie. the number)

so later on when:

Code:
 if %tmp1 < %tmp2 


it's saying IF (the actual alpha, and not its value) "%xa" is less than (same again) "%xb"...

Thanks anyway, any idea anyone?

#28743 09/06/03 02:34 AM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
Try:
Code:
alias find.max.var {
  var %i = 2,%v = $var(%[color:green]x[/color]*,0),%b = $var(%[color:green]x[/color]*,1).value,%r = $var(%[color:green]x[/color]*,1)
  while ( %i <= %v ) {
    if ( $var(%[color:green]x[/color]*,%i).value > %b ) {
      var %b = $ifmatch,%r = $var(%[color:green]x[/color]*,%i)
    }
    inc %i
  }
  return %r
}

#28744 09/06/03 09:44 AM
Joined: Mar 2003
Posts: 63
N
Babel fish
Offline
Babel fish
N
Joined: Mar 2003
Posts: 63
O yes, sorry, forgot about that, try replacing the line :
if %tmp1 < %tmp2 { var %found = %tmp2 }
by :
if $eval(%tmp1,2) < $eval(%tmp2,2) { var %found = %tmp2 }
I think it should work !
Otherwise, the Collective are never wrong so you also have their solution smile


Link Copied to Clipboard