Just go to http://msdn.microsoft.com/library and search for CreateFile 
function. Look at the arguments for the function and you will find constants 
that when passed with CreateFile, that when attempting to open an existing 
file will return a value that can be deciphered as the file is existing.




----- Original Message ----- 
From: "John Docherty" <[email protected]>
To: "RBASE-L Mailing List" <[email protected]>
Sent: Tuesday, January 29, 2013 5:02 AM
Subject: [RBASE-L] - Re: Is a file Open?


Stephen,

While I see you have a solution for this I (with some help from others on
the list) wrote a plugin in Delphi back in 2006 to check for a file being
open. I have tried to resurrect it for 9.5 but it seems that things have
changed a bit since then. If anyone on the list can perhaps give me a few
tips as to what one needs to do now, maybe I can update it.

Thank you.

Regards,

John Docherty

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Stephen
Markson
Sent: Tuesday, 29 January 2013 8:01 a.m.
To: RBASE-L Mailing List
Subject: [RBASE-L] - Re: Is a file Open?

Unfortunately, for a variety of reasons, the unique file name solution will
not work in our environment.

However, as you say, nothing is impossible and the following will work for
us:

Since I am about to create a new report or text file, I don't mind deleting
it first. If the file is open, then R> DELETE filename will generate error
2262: -ERROR- Failed deleting filename.

Problem solved!


Regards,

Stephen Markson
The Pharmacy Examining Board of Canada
416.979.2431 x251


> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of A.
> Razzak Memon
> Sent: Monday, January 28, 2013 1:15 PM
> To: RBASE-L Mailing List
> Subject: [RBASE-L] - Re: Is a file Open?
>
> At 01:03 PM 1/28/2013, Stephen Markson wrote:
>
> >Thanks Razzak,
> >
> >Is it possible to detect if a file is open?
>
> You are welcome, Stephen!
>
> TTBOMK, currently, there is no function available to detect if an
> external file is open or not. Thus, the reason to provide you with a
> sample code to help you take advantage of R:BASE functions in a
> multi-user environment.
>
> Having said that, as you may know, nothing is impossible!
>
> Very Best R:egards,
>
> Razzak.
>
>
> > > -----Original Message-----
> > > From: [email protected] [mailto:[email protected]] On Behalf Of A.
> > > Razzak Memon
> > > Sent: Monday, January 28, 2013 12:45 PM
> > > To: RBASE-L Mailing List
> > > Subject: [RBASE-L] - Re: Is a file Open?
> > >
> > > At 11:27 AM 1/28/2013, Stephen Markson wrote:
> > >
> > > >How does one check if a file is open (in use)?
> > > >
> > > >If you do R> OUTPUT somefile, or R> PRINT reportname OPTION
> > > PDF|FILENAME
> > > >somefile, and someone has the file open, then nothing is produced.
> > >
> > >
> > > Stephen,
> > >
> > > In a multi-user environment, you should adapt the technique to
> > > dynamically create a unique file name to avoid such instances.
> > >
> > > You may use the new (CVAL('GUID')) function to create a unique
> > > file name.
> > >
> > > Here are two simple examples that you may modify and adopt, if you
> wish.
> > >
> > > -- Example 01
> > > -- Using R:BASE eXtreme 9.5 (64)
> > >     IF (CVAL('DATABASE')) <> 'RRBYW18' OR (CVAL('DATABASE')) IS
> > > NULL THEN
> > >        CONNECT RRBYW18 IDENTIFIED BY NONE
> > >     ENDIF
> > >     CLEAR VARIABLE vPDFFileName
> > >     SET VAR vPDFFileName TEXT =
> > > ((CVAL('NetUser'))+'_'+(CVAL('GUID'))+'.PDF')
> > >     PRINT InvoiceSummary +
> > >     OPTION PDF +
> > >     |FILENAME .vPDFFileName +
> > >     |SHOW_CANCEL_DIALOG ON +
> > >     |TITLE Running R:BASE Your Way! +
> > >     |SUBJECT Invoice Summary +
> > >     |AUTHOR R:BASE eXtreme 9.5 +
> > >     |KEYWORDS Invoice Summary +
> > >     |OPEN ON
> > >     CLEAR VARIABLES vPDFFileName
> > >     RETURN
> > >
> > > -- Example 02
> > > -- Using R:BASE eXtreme 9.5 (32)
> > >     IF (CVAL('DATABASE')) <> 'RRBYW18' OR (CVAL('DATABASE')) IS
> > > NULL THEN
> > >        CONNECT RRBYW18 IDENTIFIED BY NONE
> > >     ENDIF
> > >     CLEAR VARIABLE vPDFFileName
> > >     SET VAR vPDFFileName TEXT = +
> > >     ((CVAL('NetUser'))+'_'+(FORMAT(.#NOW,'MMDDYYYY_HHNN'))+'.PDF')
> > >     PRINT InvoiceSummary +
> > >     OPTION PDF +
> > >     |FILENAME .vPDFFileName +
> > >     |SHOW_CANCEL_DIALOG ON +
> > >     |TITLE Running R:BASE Your Way! +
> > >     |SUBJECT Invoice Summary +
> > >     |AUTHOR R:BASE eXtreme 9.5 +
> > >     |KEYWORDS Invoice Summary +
> > >     |OPEN ON
> > >     CLEAR VARIABLES vPDFFileName
> > >     RETURN
> > >
> > > Hope that helps!
> > >
> > > Very Best R:egards,
> > >
> > > Razzak.
> > >
> > > www.rbase.com
> > > www.facebook.com/rbase
> > >
>


Reply via email to