1. a text filter (with a minor problem - help!)
Inclosed with this is an example of a text filter in Euphoria. Now and
then one gets a documented with form feeds which one does not want;
recently I got a bit of Pascal source from a CD which would not compile
-- because of the many form feeds in it. So I quickly put together a
filter to remove them.
Usage: ex stripff [input_file_name] [output_file_name]
The original was written in C, but as an experiment I made this Euphoria
version as well. The program has a built-in timer, and different
versions of the program gave these results on my computer (filtering a
213905-byte text file):
Borland C++ 4.5 6 sec
Euphoria 1.5 11 sec
Turbo C 2.0 13 sec
So Euphoria does not do too badly!
But the program has one fundamental flaw, and I do not know what to do
about it. To determine the length of the input file, I did
FILE_HANDLE = open (FILE_NAME,"ab")
FILE_LENGTH = where(FILE_HANDLE)
close(FILE_HANDLE)
-- followed by FILE_HANDLE = open (FILE_NAME,"rb")
but this trick cannot work if the input file is read-only!!! Is there
another way to find out the length of a file?
section 1 of 1 of file strff.zip < uuencode 5.32 by R.E.M. >
2. Re: a text filter (with a minor problem - help!)
The dir() command can return attributes about a particular file or
directory, one of which is the file size. If you know the size of a file,
you know how long it is in bytes.
Hope this helps
David Gay
"A Beginner's Guide To Euphoria"
http://www.geocities.com/SiliconValley/Vista/4346
3. Re: a text filter (with a minor problem - help!)
> The original was written in C, but as an experiment I made this Euphoria
> version as well. The program has a built-in timer, and different
> versions of the program gave these results on my computer (filtering a
> 213905-byte text file):
>
> Borland C++ 4.5 6 sec
> Euphoria 1.5 11 sec
> Turbo C 2.0 13 sec
>
> So Euphoria does not do too badly!
Are you sure???? That's great!
> But the program has one fundamental flaw, and I do not know what to do
> about it. To determine the length of the input file, I did
>
> FILE_HANDLE = open (FILE_NAME,"ab")
> FILE_LENGTH = where(FILE_HANDLE)
> close(FILE_HANDLE)
> -- followed by FILE_HANDLE = open (FILE_NAME,"rb")
Use the dir() function instead. One of the return values it gives is
the file size.
>
> but this trick cannot work if the input file is read-only!!! Is there
> another way to find out the length of a file?
>
> section 1 of 1 of file strff.zip < uuencode 5.32 by R.E.M. >
>
>
Regards,
Daniel Berstein
danielberstein at usa.net
http://www.geocities.com/SiliconValley/Heights/9316