PWB Extensions Help (ext.hlp) (Table of Contents; Topic list)
Using Files in Extensions
                                             Up Contents Index Back
─────PWB Extensions─────────────────────────────────────────────────────────
 
     Files must be accessed through the PWB internal file system rather
     than through the DOS file system. A buffer containing the text of
     the file is maintained for each open file. In order to do any
     operation on a file buffer, you must have the handle of the file
     buffer. PWB file handles have PFILE type.
 
     The constant PNULL is defined as a null file pointer. PNULL is not
     the same as NULL. You will get compiler warnings if you use NULL
     for file functions that return null or take null arguments.
 
     You can get the handle (PFILE) of a file if you have one of the
     following:
 
     File name         This can be a partial or complete specification
                       according to MS-DOS rules. There are shortcut
                       defaults for getting the handle of the current
                       file. Use FileNameToHandle or GetEditorObject for
                       open files, and AddFile for new files.
 
     Short name        This is a base name only maintained for open
                       files. Use FileNameToHandle.
 
     Access number     For example, the third most recently accessed
                       file has number 3. Use GetEditorObject.
 
     The cycle for opening, processing, and closing a file is:
 
       1. Open new buffer with AddFile or get handle of existing buffer
          with FileNameToHandle.
 
       2. Read the contents of disk file into memory or initialize a
          pseudofile with FileRead.
 
       3. Set file flags with SetEditorObject.
 
       4. Process text in the file.
          See Processing Text
 
       5. Save by writing buffer to disk with FileWrite.
 
     To open a file and make it the current file in one step, use
     fSetWindowWithFile.
 
     Deleting a file can mean several things, depending upon the task
     you want to perform:
 
       1. You can delete the text in an open file buffer with DelFile.
          You may want to do this to clear a work file (such as a
          pseudofile) for reuse.
 
       2. You can remove a file buffer from the list of open files with
          RemoveFile. This is seldom necessary.
 
       3. You can delete a file from the disk. PWB provides no callback
          to do this, but you can call the operating system directly.
 
     Other common file operations include:
 
     Task                                          Callback Function
 
     Display or edit a file in a pop-up box        PopUpBox
     Get the number of lines in a file             FileLength
     Process files matching a wildcard pattern     ForFile
     Get information about a file                  GetEditorObject
     Set various attributes of a file              SetEditorObject
                                    -♦-