mIRC Home    About    Download    Register    News    Help

Print Thread
#110767 10/02/05 05:29 PM
Joined: Aug 2004
Posts: 237
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Aug 2004
Posts: 237
I want to count the number of lines in all files in mircdir where filename is, usingg wildcards, LethPhaos*.mrc

#110768 10/02/05 06:13 PM
S
SkyD
SkyD
S
I dont know..

Last edited by SkyD; 10/02/05 06:15 PM.
#110769 10/02/05 06:14 PM
Joined: Sep 2004
Posts: 237
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Sep 2004
Posts: 237
$lines(filename)
Returns the total number of lines in the specified text file.

$lines(c:\irc\kicks.txt) returns the total number of lines in c:\irc\kicks.txt



type /help $lines to get there in the help file. Im not sure if that will read mrc files the same way, they are just text files, but windows doesnt treat them that way unless you specify ...I think.

#110770 10/02/05 06:20 PM
N
nycdiesel
nycdiesel
N
This may work, havent tested it:

Code:
alias count_files {
; $count_files(<wildcard>)
; //echo -a $count_files(LethPhaos*.mrc)
if ($1) {
; ^ ensure $1 is present
var %a = 0
; ^ setup a local variable with 0 as it's value
.echo -q $findfile($mircdir,$1,0,inc %a $lines($shortfn($1-)))
; ^ search through the mIRC directory for files matching the $1 parameter you supplied. Read up on $findfile for depths. Then increments %a with the number of lines of each file found
return $iif(%a,%a,n/a)
; ^ returns the total number of lines from all files found
; ^ the $iif just ensures %a is present, if not, returns n/a
}
}

Last edited by nycdiesel; 10/02/05 06:20 PM.
#110771 10/02/05 06:40 PM
Joined: Aug 2004
Posts: 237
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Aug 2004
Posts: 237
I'll try to use the $lines together with a $calc, see what I can create. Thx!

#110772 10/02/05 06:41 PM
Joined: Aug 2004
Posts: 237
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Aug 2004
Posts: 237
Quote:
I dont know..

=> if you don't know, don't reply wink

#110773 10/02/05 06:48 PM
Joined: Nov 2003
Posts: 2,321
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,321
Code:
alias dirlines {
  var %lines
  .echo -q $findfile($1,$2,0,inc %lines $lines($1-))
  return %lines
}


//echo -a $dirlines($mircdir,Lethpaos*.mrc)

#110774 10/02/05 07:04 PM
Joined: Aug 2004
Posts: 237
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Aug 2004
Posts: 237
alias codedlines {
var %i = 1, %total
while $findfile($mircdir,LethPhaos Script -- *.mrc,%i) {
%total = $calc($lines($v1) + %total)
inc %i
}
msg $chan My mIRC is extended with %total lines of self-written code.
}
Selfwritten, works, didn't read tidy's one yet, I'll take a look at it.

#110775 10/02/05 10:33 PM
D
DaveC
DaveC
D
I have an idea for ya (just an idea of course, you must do your own ones ok)

Code:
;This alias counts the number of lines of self written code and messages the channel with the result.
;usage is from a event only that produces a $chan value.
alias codedlines {
  ;
  ;Loop Counter set below
  var %i = 1
  ;
  ;Total lines count set below
  var %total = 0
  ;
  ;loop untill no file is located using $findfile, based on loop counter number
  while $findfile($mircdir,LethPhaos Script -- *.mrc,%i) {
    ;
    ; Code enters here only if a file exists
    ;
    ;Add tot total lines the number of lines in the current file
    %total = $calc($lines($v1) + %total)
    ;
    ;increment the loop counter for the next file
    inc %i
    ;
    ;loop ends return to top of loop
  }
  ;
  ;Display the number of lines of self-written code to $chan, which means this must be beiong called from a event.
  msg $chan My mIRC is extended with %total lines of self-written code.
  ;
  ;alias ends.
}



That way you get 20 extra lines on your code count.

#110776 10/02/05 10:51 PM
Joined: Aug 2004
Posts: 237
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Aug 2004
Posts: 237
^^ lol DaveC, I don't cheat smile


Link Copied to Clipboard