Search    
 

   
 

 
PRAGMA PROGRAM REFERENCE MANUAL
Index
All Operation

Expand All      ADDENDUM
CLOSE ALL FILES CAF Standard Verb File Access Operation
Target =

Releases all records and closes all PFM and BTRIEVE files.
The PRVOCAB, PRMSG and PRSTD files are also closed.

Any ASCII file opened with a DOS OPEN verb is NOT closed. Neither are files
that have been opened with a SYSTEM CALL.

CLOSE ALL FILES





SEE ALSO: CLOSE FILE / EXTERNAL CLOSE FILE / SYSTEM CALL

CLOSE ALL FILES (CAF)
CLOSE FILE (CF)
EXTERNAL CLOSE FILE (XCF)



The verb CLOSE ALL FILES closes all open PFM files and Btrieve files and also releases all records of these files that may have been locked.

CLOSE FILE closes one specific file on the internal file path, whereas EXTERNAL CLOSE FILE closes one specific file on the external file path. Any locked record of that file will be released.


Be aware that when closing a file the THIS pointer of that file is lost. For instance, you cannot get a record of a file, close that file and then save the modified record. PRAGMA will have lost the information of which record you wanted to update.


In addition to closing all the open user files, CLOSE ALL FILES also closes the files PRVOCAB.PFM, PRMSG.PFM and PRSTD.PFM, but reopens them immediately. But any ASCII file opened with a DOS OPEN verb (DOS OPEN APPEND, DOS OPEN CREATE and DOS OPEN READ) will not be closed. Nor will any file that might have been opened by a SYSTEM CALL be closed.


Usually in PRAGMA you don't have to be concerned with opening or closing files. The only exceptions are ASCII files opened with the DOS OPEN verbs.

These verbs for closing files are only to be used in special circumstances as when you want to ensure that an important file is shut as a precaution against file corruption in case of an inorderly shutdown of PRAGMA. Or if the operating system or Btrieve won't let you keep more than a certain amount of files open.

Another reason to close a file or all files is to force the operating system to write the data to disk. But be aware that even if you close files in PRAGMA, the operating system may not immediately perform the task if a cache is installed.


MULTIUSER ENVIRONMENT

But what happens in a multiuser environment like UNIX or in a network, where files are accessed by more than one user? Does closing a file within PRAGMA really close all the files?


UNIX has a data space for each user. In that data space UNIX records what files are open, what locks are pending, etc. All of this is done on a per user basis. So, just as UNLOCK ALL only unlocks what you have locked and nothing else, so closing a file only closes what you have opened.

If five people have the same file open, for instance, and one user does closes that file, that file only gets closed for that one user. As far as the other users are concerned, nothing has happened at all.

From the operating system point of view, the file is not really closed until all users that have it open have closed it. But to a user, it is not known if other users have a file open or not. He can only close the file for himself, and not for anyone else.

The effect of closing a file is only to write back to the operating system all of your changes. It does not totally close the file from the system point of view.

So, the important point in a multiuser system is that you need to have two points of view. That of the end user and that of the operating system.


The Novell network server handles files accessed by more than one user in a similar way to UNIX.


Usually this is not important. But if you want to write a backup routine and invoke it from within PRAGMA, be very careful. You should not do it for a multiuser environment. If you attempt to backup a file that is open for another user, it will not work, or at best, it will work very slowly and cause a slowdown of everything.



 

CustomWare® is a registered trademark of CustomWare Designs, Inc. All rights reserved.
CustomWare® is a registered servicemark of CustomWare Designs, Inc.  All rights reserved.
All images and designs on this web site are copyrighted© 2021.
v t