You might want to send the output of the DIR command to NUL


OUT NUL

DIR .vFile2Find

SET VAR vErrSave1 = .vErrVar

OUT SCREEN



NUL is a bucket that just throws away any output sent to it.

This is good practice when you won't be using the output generated




From: [email protected] [mailto:[email protected]] On Behalf Of Karen Tellef
Sent: Wednesday, August 06, 2014 10:50 AM
To: RBASE-L Mailing List
Subject: [RBASE-L] - Re: Counting files in a directory

Ah!   I never thought of using an error variable with a "dir".   I think I'll 
use that, thanks Albert!

Karen

-----Original Message-----
From: Albert Berry <[email protected]<mailto:[email protected]>>
To: RBASE-L Mailing List <[email protected]<mailto:[email protected]>>
Sent: Wed, Aug 6, 2014 10:47 am
Subject: [RBASE-L] - Re: Counting files in a directory
Try this Karen - I needed to do this for another app, and came up with this. If 
the file does not exist, it returns error 2255; if the file exists verrsave is 
0.

SET ERR MESS OFF
SET VAR vFile2find text = "*.rx5"
SET VAR vErrSave INTEGER
SET ERROR VAR vErrVar
DIR .vFile2Find
SET VAR vErrSave1 = .vErrVar

SET VAR vFile2find text = "*.rx1"
DIR .vFile2Find
SET VAR vErrSave2 = .vErrVar

SHOW VAR vErrSave%

RETURN

Albert
On 8/6/2014 8:55 AM, Karen Tellef wrote:
Using 9.5, 64-bit, and have the Power Plugin pack available to me.  Back in 
7.6, ChkFile worked with wildcards even though the documentation said the 
results would be inconsistent.  For example, if you wanted to see if there are 
any excel files in a directory, you could:
        set var vcount = (chkfile('c:\temp\*.xls'))
It would return 1 if there were files, 0 if there wasn't.

So now I'm in 9.5 and I want to check if there are files in a directory.  The 
ChkFile doesn't work for this, and I looked thru the plugin document and don't 
see a filecount.  Is there a nice elegant way to do this now, or do I have to 
do directories to a file to a temp table, etc...

Karen



Reply via email to