mIRC Home    About    Download    Register    News    Help

Print Thread
#125904 23/07/05 07:06 AM
Joined: Feb 2005
Posts: 74
S
SkyD Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: Feb 2005
Posts: 74
Hey.. -- COMMAND = !TOP3 --
How can i make a script which take out 3 best numbers from "users/,$nick" and say it to user... ~~

Sorry for English!!


[color:red]m[color:blue]IRC[color:green] for EvEr

#125905 23/07/05 10:10 AM
Joined: Feb 2005
Posts: 74
S
SkyD Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: Feb 2005
Posts: 74
hey... HELP me... PLZZ..!! HELP, HELP, HELP!!


[color:red]m[color:blue]IRC[color:green] for EvEr

#125906 23/07/05 11:24 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
I doubt anyone understood what you said!

#125907 23/07/05 01:08 PM
Joined: Feb 2005
Posts: 74
S
SkyD Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: Feb 2005
Posts: 74
uhh, my english ir very bad..
I have many files - file1.txt, file2.txt, file3.txt, file4.txt ...
in these's files ar 10lines and 3line in all files is the numbers..
I need a script which take out from these files 3. line and show the TOP 3 higher numbers..

Example how it can be:
file1.txt - 3line = 300
file2.txt - 3line = 102
file3.txt - 3line = 340
file4.txt - 3line = 321

TOP 3 = 1. file3.txt 2. file4.txt 3. file1.txt


[color:red]m[color:blue]IRC[color:green] for EvEr

#125908 23/07/05 02:23 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Code:
alias top3 {
  var %x = 1
  while (%x <= 3) {
    var %n = $$1
    if ($isfile($+(file,%n,.txt))) echo -a $read($+(file,%n,.txt),%x)
    inc %x
  }
}


/top3 1 - Returns the first three lines from file1.txt.
/top3 5 - Returns the first three lines from file5.txt.
/top3 10 - Returns the first three lines from file10.txt.

If file10.txt doesn't exist, nothing will get echoed. What it does is check to see if the file (fileN.txt) exists before processing.

-Andy

#125909 23/07/05 10:42 PM
Joined: Feb 2004
Posts: 206
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Feb 2004
Posts: 206
Quote:
Code:
alias top3 {
  var %x = 1
  while (%x <= 3) {
    var %n = $$1
    if ($isfile($+(file,%n,.txt))) echo -a $read($+(file,%n,.txt),%x)
    inc %x
  }
}

-Andy


Code:
alias top3 {
  var %n = $$1  
  var %x = 1
  if ($isfile($+(file,%n,.txt))) {
    while (%x <= 3) {
     echo -a $read($+(file,%n,.txt),%x)
    inc %x
    }
  }
}


The minor modificatin means that you only need to check for the existence of the file once.

Code:
alias top3 {
  var %fname = $+(file,$1,.txt)  
  var %x = 1
  if ($isfile(%fname)) {
    while (%x <= 3) {
     echo -a $read(%fname,%x)
    inc %x
    }
  }
}


I would go the next step (listed above), for readability. The use of '$$' in the original codehas no effect, as you use %n reardless of whether theere was anything in $1 or not. This version (above) will look in a default file "file.txt" if no arguments are passed. If you want there to be no file name, then use $$1 instead of $1.

or perhaps you could use the line :
Code:
    if ($isfile(%fname) && $0) {


which will check to see if $0 >0 (thus the presence of arguments to the command).

not tested.

Cheers,

DK


Darwin_Koala

Junior Brat, In-no-cent(r)(tm) and original source of DK-itis!

Link Copied to Clipboard