PDA

View Full Version : Windows findfile



SpinMan
06-23-2008, 08:28 AM
We're starting to migrate to PV-Wave 9x for Windows from VMS. One of the most useful functions we use is findfile where it's possible to do a search on subdirectories, ala findfile('data$drive:[folder...]*.csv'). The user manuals aren't too specific for how to do the same with findfile, or filepath. Can y'all help?
SpinMan

donb
06-23-2008, 10:30 PM
FINDFILE is quite the useful routine; and it is rather machine dependent in it's behavior.

On UNIX, we fork/exec the UNIX 'find' command. On OpenVMS and Windows, we make a system call that basically executes the DIR command and returns the results as an array of strings.

OpenVMS, with the "..." directory option, works very similar to the UNIX 'find'; it recursively examines all subdirectories for file name matching and returns the directory path along with the filename as you would expect.

For Windows, FINDFILE only examines the current directory. Alternatively, you can spawn a process and use the /S option to the DIR command:

WAVE> CD, 'c:\vni\wave'
WAVE> SPAWN, 'dir/s *.pro', results
WAVE> INFO, results
RESULTS STRING = Array(1104)

The issue here is you're left with DOS results where it returns the directory name and then all the file attributes. You'll have to do some PV-WAVE string manipulation commands to massage the array into what you really need (filename prepended with the directory path).

Another option - there are a number of UNIX commands that have been ported to Windows. If you install those commands on your machine ('find' is one of the commands included), then you can call them from within PV-WAVE and the expected results are returned. If all your UNIX commands are installed in c:\bin, here are the commands:

WAVE> spawn, 'c:\bin\find . -name *.pro', results
WAVE> INFO, results
RESULTS STRING = Array(946)

Let me know if this helps,

Don B.

ed
06-24-2008, 06:48 AM
For Windows, FINDFILE only examines the current directory. Alternatively, you can spawn a process and use the /S option to the DIR command:

WAVE> CD, 'c:\vni\wave'
WAVE> SPAWN, 'dir/s *.pro', results
WAVE> INFO, results
RESULTS STRING = Array(1104)

The issue here is you're left with DOS results where it returns the directory name and then all the file attributes. You'll have to do some PV-WAVE string manipulation commands to massage the array into what you really need (filename prepended with the directory path).

To improve on this method, you can use "dir /s /b" to return only bare file names plus directory information (but no excess DOS info):

WAVE> spawn, 'dir /s/b *.pro', results
WAVE> print, results(0:10)
c:\vni\wave\demo\arl\f_gridemo2.pro
c:\vni\wave\demo\arl\f_gridemo3.pro
c:\vni\wave\demo\arl\f_gridemo4.pro
c:\vni\wave\demo\arl\grid_demo2.pro
c:\vni\wave\demo\arl\grid_demo3.pro
c:\vni\wave\demo\arl\grid_demo4.pro
c:\vni\wave\demo\arl\grid_demo5.pro
c:\vni\wave\demo\arl\img_demo1.pro
c:\vni\wave\demo\arl\poly_demo1.pro
c:\vni\wave\demo\arl\sphere_demo1.pro
c:\vni\wave\demo\arl\sphere_demo2.pro

SpinMan
06-24-2008, 08:58 AM
thanks folks! i wasn't sure where i was, but the cd command helped as well.