Line count in macro read_file()
AVKuznetsov
kuzn at htsc.mephi.ru
Tue Apr 8 12:31:22 CEST 2008
On Tue, 8 Apr 2008 01:36:49 -0700 (PDT)
YT Lim <ytlim23 at yahoo.com.au> wrote:
> Is there a way to know how many lines of text have been read by the macro subroutine read_file()?
>
> /Y.T.
>
Hi,
you can try the following macro
define read_file_line_count{
string = read_file($1) # File name is an argument.
if(!$read_status)
return -1 # Reading error.
if(string == "")
return 0 # Empty file.
for(i=1, start=0; search_string(string, "\n", start) >= 0; i++)
start = $search_end
return i # Number of lines.
}
Alexey
More information about the Discuss
mailing list