mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2003
Posts: 6
B
Bungle Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Mar 2003
Posts: 6
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?


- cF
Dedicated helper for rent.
Joined: Mar 2003
Posts: 6
B
Bungle Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Mar 2003
Posts: 6
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,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
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.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Mar 2003
Posts: 6
B
Bungle Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Mar 2003
Posts: 6
it returns:

* /echo: insufficient parameters

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

Joined: Feb 2003
Posts: 23
C
Ameglian cow
Offline
Ameglian cow
C
Joined: Feb 2003
Posts: 23
I tried it and it works,make shure that "return %a" is on a new line grin

Joined: Mar 2003
Posts: 6
B
Bungle Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Mar 2003
Posts: 6
i just keep getting the exact same problem

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


Link Copied to Clipboard