Would it make sense to ask RBase for a Plugin that would do this ?
I have some very crude code that works....but it's not very "elegant"
--my patient id number
SET VAR vpnum REAL
IF vpnum IS NULL THEN
RETURN
ENDIF
--convert to a text value, use the value to create the path to evaluate
SET VAR vpnumtxt = (CTXT(INT(.vpnum)))
SET VAR vpath = ('H:\' + .vpnumtxt + '\')
SET VAR vdocfolder TEXT
--use the run using command to change the document type such as ekg, labs, etc
SET VAR vdoctype = .%1
CLEAR VAR %1
SET VAR vdocfolder = (.vpath + .vdoctype)
OUTPUT c:\scratch\countfil.txt
DIR .vdocfolder
OUTPUT SCREEN
--the table countfile has 1 column, 80 characters wide, text
DELETE FROM countfile
LOAD countfile FROM c:\scratch\countfil.txt AS FORMATTED USING linedata 1 80
--from here, you need custome code, you can delete every line that does not
contain '.'
--to get a count of how many files there are total
--after the extra rows are gone, you can use sget, slen etc to extract the size
of the file
--in this example, I want count the number of pdf files in the folder
DELETE FROM countfile WHERE linedata NOT CONTAINS '.pdf'
SELECT COUNT linedata INTO vcount FROM countfile
SET VAR vcounttxt = (CTXT(.vcount))
SET VAR vcomponentid = ('id_' + .vdoctype)
--now update the appearance of the buttons, green for active, red for no pdf
files
IF vcount > 0 THEN
SET VAR vcaption = (LUC(.vdoctype & .vcounttxt))
PROPERTY .vcomponentid caption .vcaption
PROPERTY .vcomponentid color GREEN
ELSE
SET VAR vcaption = (ULC(.vdoctype))
PROPERTY .vcomponentid color RED
PROPERTY .vcomponentid caption .vcaption
ENDIF
RETURN
________________________________
From: Mike Byerley <[email protected]>
To: RBASE-L Mailing List <[email protected]>
Sent: Monday, December 19, 2011 1:25 PM
Subject: [RBASE-L] - Re: Counting items in a folder
You can check for existance with RBase ChkFile function.
Already have a 97% finished DLL that has a variety of File functions
including FileSize, FileCount (based on one or a series of File extensions),
FileVersionInfo and so on. Maybe in a few days or a week (depending on how
much interruption holiday stuff does) I can get it done sufficiently to put
in the wild for use. I do know it's been long enough since I worked on it
that the source code doesn't match what I started in the Help File, but like
I said, it's close to done.
----- Original Message -----
From: "Michael J. Sinclair" <[email protected]>
To: "RBASE-L Mailing List" <[email protected]>
Sent: Monday, December 19, 2011 12:08 PM
Subject: [RBASE-L] - Re: Counting items in a folder
Hi Mike,
There are a few scenarios where this would be helpful.
First checking for the existance of any file in the folder would be helpful
for error handling.
Sometimes files are created which should have a minmum size if the data is
good. Corrupt data ends up creating a file that is smaller than a certain
size. Being able to check for the existance of any files with a filesize
that is smaller than a predetermined limit would help the application to
call for help, call a different app, send an email etc.
Looking for the existance of a certain number of files such as jpg files
could trigger an app to create a single pdf file out of the group of jpg
files.
I would like to be able to count the number of files using various criteria
and display them by changing the properties (color and text) of certain
buttons that do things to the files, ie red for no files, green plus a
number to indicate the presence of a certain number of files in a folder.
Mike
________________________________
From: Mike Byerley <[email protected]>
To: RBASE-L Mailing List <[email protected]>
Sent: Monday, December 19, 2011 9:39 AM
Subject: [RBASE-L] - Re: Counting items in a folder
Mike,
Could you elaborate a bit on what you are trying to do? Filesize or
Filecount are pretty easy, but why do you want to search or display a file
that is of a certain size?
----- Original Message -----
From: "Michael J. Sinclair" <[email protected]>
To: "RBASE-L Mailing List" <[email protected]>
Sent: Sunday, December 18, 2011 8:38 AM
Subject: [RBASE-L] - Counting items in a folder
: Hi All,
: How would you count the number of files in a folder and capture that value
into a variable (assume no subfolders)?
: (If there were a PLUGIN for that, it would be great if the PLUGIN had the
ability to specify file characteristics that would limit the count, such as
count only files that are a certain size or created on or after a certain
date, had a certain extension, etc.)
: Mike