mIRC Home    About    Download    Register    News    Help

Print Thread
B
Bungle
Bungle
B
I am having some problems in writing code to find the highest number in a text file (when they are arranged going down the file). I think it would use loops and if/else statments, but i'm not sure how they would be written. IIf anyone can give me an example code similar to this, or show me any tutorials on how to write it, i'd be grateful,

- Bungle

Joined: Mar 2003
Posts: 272
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Mar 2003
Posts: 272
Can we get the exact syntax of the text file please?

B
Bungle
Bungle
B
to give the way the file goes:

word1.4534
word2.342
word3.6511
..etc..

i know about $gettok etc to separate them, just insure about getting the highest 2nd token (number)

- Bungle

Joined: Jan 2003
Posts: 2,125
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,125
Code:
alias highestnum {
  window -h @@
  filter -fwcute 2 46 [color:blue]yourfile.txt[/color] @@
  var %a = $gettok($line(@@,1),2,46)
  close -@ @@
  return %a
}


Example usage: //echo -a $highestnum

Unfortunately I don't have the time to explain how/why this works right now, so try to read the help file on /filter. If you still have questions, post back and someone (or me, tomorrow) will help.

B
Bungle
Bungle
B
it returns:

* /echo: insufficient parameters

..and i did change the file to where to numbers are in smirk

C
cybah
cybah
C
I tried it and it works,make shure that "return %a" is on a new line grin

B
Bungle
Bungle
B
i just keep getting the exact same problem

Joined: Dec 2002
Posts: 698
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 698
make sure you are using the -a switch.
//echo -a $highestnum


Link Copied to Clipboard