Programmer: Kevin S. Gallagher [70034,2313]

Presented here as the main attraction is FileScan() which was modeled after
one that has the same name in Dirk Lesko's FUNCky II developement library.
The primary purpose of cloning FileScan was to show a fellow programmer how
to code functions that might save them time by having a black box routine.
Many new programmers may wonder how a function was put together in a third
party library, which does not include source code, and here we can show one
way which it might have been coded if done in Clipper. I'm sure that this
function (filescan) was coded with either assembler or c and not Clipper.
This is because Dirk utilizes a 'core' library and a surface library. The
surface library talks to the core library were the surface library is geared
for Clipper and the core library contains the primitive code done in either
C or assembler. If the same function had been coded with say Grumpfish
library you would have 99% of the code in Clipper and that code would be
available to you since that is how Greg Lief works. The remaining would have
been in C or assembler and that code would not be available. If done with
SuperLib then all code would be available to you the developer. Each of the
third party libraries have there good and bad points. Take for example the
Grumpfish library, i wouldn't want to go out on a contract job without this
library. If i could pick one library for 99% of Clipper coding it would be
Greg's Grumpfish library. On the otherhand if i was coding in C or FORCE
languages then FUNCky II would be my main pick for libraries. I have tried
SuperLib but it just is not my cup of tea, don't get me wrong it is a very
good library.

About code in TEST.PRG
The code in this program file goes abit overboard to show off how one might
use filescan. The main focus is on the function which is called upon when
filescan gets/builds an array from the filespecs sent to it in parameter
one. This function is sent to FileScan in the form of a code-block that is
passed two parameters {|param1,param2| MyFunc(param1,param2)} which is used
with eval(). I use eval() within a aeval() which passes a filename without
a path as parameter one, and parameter two contains the same filename but it
has a path added onto the front of the filename. This path is added by the
function called Pather() which is seen only within isfile.prg so that if you
have a function be the same name it does not conflict with your functon or
a function with the same name as one in another third party library. In the
Pather function i use ft_default() to get the runtime drive letter rather
then resorting to one that would use plain old Clipper which would slow down
the processing and might run amuck if there are disk errors or the program
is happening to be running on a floppie drive (heaven forbid). Ft_default
was coded by Ted Means who appears to be the guru of assembler code in the
Clipper language, so i feel comfortable using it. Anyways in test.prg i do
three calls to filescan, and the first one will fail with BASE 1001 which
indicates that the function within the macro-expanded string into a code
block was not linked or spelled incorrectly. This was done on purpose so
you can see what could occur in this type of situation. We are allowed to
continue since i contained the damage inside of control section of code by
enclosing it inside of begin/end sequence and recovering with recover using
clause part of the sequence statement. The screen output show the error and
also outputs -1 for total bytes counted which indicates there was an error.
The remaining two calls work - but only if the filespecs exist on _your_
computer.

In the second call to filescan the filespecs are:
   *.prg
   C:\DOS\a*.exe
   C:\*.*"

if C:\DOS does not exist then nothing is done, and if C:\DOS exist, but has
no executable files ".exe" starting with the letter "A", then again there
will be nothing to do.  I assume you do have a C: drive and it is populated 
with a bare minimum of autoexec.bat, config.sys

In the last call to filescan i look at one of the directories for an old
friends, which is most used editor - Brief. Well at least on 486 and lower
computers. So if you do not have this directory then change its names to
one that exist, like were you house Multi-Edit for instance.

   "C:\BRIEF\*.*"


In the function within the code-block MyFunc, i show the filename w/o a path
then show it's date, followed by the filename with a path. On some files i
show how many lines of text are in the file. This function that does the line
counting has hooks provided by me to allow possible searching of lines of
text for anything you want. If ISFILE.PRG or CONFIG.SYS are found then you
are asked if you would like to view them. In your program you could use this
logic to do other operations once a particular file or files are located.
For example, open the desired file (like a .dbf) and modifiy or append info
within it etc.. There is a call in MyFunc that when it hits directories 
shows file(s) under it. This has merit for many operations, i'm sure you can
find one or more things to use this for. Please note that  ShowDirs() is very
crude and is for a quick n dirty demo.

                                                                     
FileScan
   is for scanning files and directories for names that match  
   a pattern with specific attributes. The filescan function has been   
   modeled after one with the same name in Lesko's FUNCky II library.   
   I did it for teaching another programmer the inner workings of how   
   it might be coded, even though Dirk most likely used C language for  
   the filescan function.                                               
                                                                     
flinecount 
   is for getting total lines of text in ascii files and has 
   hooks for searching for tokens within a ascii file. I have used it   
   on a ascii file that exceeded 300MB on a P5, and worked very well.   
                                                                     
ft_isdir 
   is for determining is a directory exist at runtime, it uses 
   the function ft_int86() from nanforum toolkit version 2.nn or 3.nn   
                                                                     
MyFunc() 
   goes to extemes to show off what can be done with FileScan  
   and would not be what we would do in real life.                      
                                                                     
ShowDirs 
   is _really_ primitive so keep it in mind when it is used!   
                                                                     

Closing up:
If you do not have nanfor.lib then use isfile.lib which is a subset of the
nanfor.lib along with the functions mentioned above. To remake isfile you
will need MS-C compiler, Borland's macro-assembler and the CA-Clipper
compiler along with of course CA-RMake - make utility. All functions have
been tested with nanfor.lib 2.nn, but not with the current release of 3.05
which was just posted this month on Compuserve. Any comments send to my
CIS address above.

BTW You may use all the code presented here, and may not sell any code
which comes from nanform library, since it is Public Domain, this also
included ft_isdir() which is not in nanform but is also labled as PD.

Enjoy

