In the Delphi  SysUtils.pas file, FileOpen expands to CreateFile under the 
covers.

The only reason to use CreateFile is to be able to utilize the myriad of 
options available, which is why I suggested it..

FileOpen will work, but there are instances where I expect either method 
"might" fail.

Notepad is an example of when the file is opened, it is read into memory, 
and then the file is closed.

You can delete the disk copy without error of any kind, save the in memory 
copy and it will reappear on disk, repeat as many times as you want.




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


Mike,

Thanks for your replies. I will have a look at the information suggested.
John Minyo has also sent me a sample so I will see if I can make this work.

I see that the original plugin used the following Delphi code:-

   fhandle:=FileOpen(fname,fmOpenRead or fmShareExclusive);
   Result:=fhandle<=0;
   Fileclose(fhandle);

I will have to see how the memory goes.

Thank you.

Regards,

John Docherty


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Mike Byerley
Sent: Wednesday, 30 January 2013 7:02 a.m.
To: RBASE-L Mailing List
Subject: [RBASE-L] - Re: Is a file Open?

BTW, It would be easier for you to convert your existing Code to a Win32 DLL
and call it using DLCall than converting to the new style Plugins that 9.1
and later require.


----- 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