1. Re: file/data sharing

At 03:51 PM 6/7/98 -0500,  Terry Constantwrote:

>Irv,
>I am new to Euphoria. But if it continues to prove out as it has been, I
>intend to use on a networked system of a client in which I will be using
>it with shared data. So, I am interested.
>--
>Terry Constant
>--

Well, here's what we need to get started:
From the shareware version of
   **  Programmer's Technical Reference for MSDOS and the IBM PC **
   by Dave Williams

Function  6Ch   Extended Open/Create  DOS 4.0+ (US)
                Combines functions available with Open, Create,
CreateNew, and Commit File
entry   AH      6Ch
        AL      00h  reserved  [which means there might be other
                                subfunctions?]
        BX      mode    format  0WF0 0000 ISSS 0AAA
                                AAA is access code (read, write,
                                                    read/write)
                                SSS is sharing mode
                                I       0       pass handle to child
                                        1       no inherit [interesting!]
                                F       0       use int 24h for errors
                                        1       disable int 24h for all
                                                I/O on this handle; use
                                                own error routine
                                W       0       no commit
                                        1       auto commit on all writes
        CX      create attribute
           bits 0       read only
                1       hidden
                2       system
                3       volume label
                4       reserved
                5       archive
                6-15    reserved
        DH      00h (reserved)
        DL      action if file exists/does not exists
           bits 0-3     action if file exists
                        0000    fail
                        0001    open
                        0010    replace/open
                4-7     action if file does not exist
                        0000    fail
                        0001    create
        DS:SI   pointer to ASCIIZ file name
return  CF      set on error
                AX      error code (unknown)
                clear
                AX      file handle
                CX      action taken
                        01h     file opened
                        02h     file created/opened
                        03h     file replaced/opened
note    When APPEND is installed, if DX=xx1x it looks only in current
        directory, if DX=xx0x it will search the full append path.
        DX is called the open flag and gives what action to take if
        the file exists or does not exist.


Function  5Ch   Lock/Unlock File Access   (DOS 3.0+)
entry   AH      5Ch
        AL      00h     to lock file region
                01h     to unlock file region
        BX      file handle
        CX:DX   4-byte starting offset from beginning of file of region
                to lock
        SI:DI   4-byte integer, high/low size of region to lock
                (in bytes)
return  CF      clear   successful
                set     AX      error code (01h, 06h, 21h, 24h)
note 1) Unlock all files before exiting or undefined results may occur.
        Programs using file locking should trap int 23h (Control-C
        Handler Address) and int 24h (Critical Error Handler Address)
        and unlock files before returning to the caller.
     2) Programs spawned with EXEC inherit all the parent's file
        handles but not the file locks.
     3) This call is explicitly supported in the OS/2 1.x DOS
        Compatibility Box.
     4) You may lock an entire file, any part of a file, or several
        parts of the same file.  For example, it would be more
        efficient to lock an area in a database containing a single
        record than to lock the entire file.  If two adjacent sections
        of a file are locked separately, they  must be unlocked
        separately - you cannot change the lock pointers and use a
        single unlock call.
     5) You should lock only as much of a file as you need and keep
        the lock only for as long as necessary.  Should a file need to
        be shared and updated often, continual locking and unlocking
        can slow file access detectably.
     6) This call returns error 01h if SHARE is not loaded.
     7) Locked files must be unlocked before the program terminates,
        or the result is undefined.
     8) A transaction-oriented algorithm for using locking is
        recommended.  In effect, assert lock, read data, change data,
        remove lock.  An application should release its lock when a
        transaction is complete.
     9) Locking past end-of-file does not cause an error.
    10) Locking a portion of a file with fn 5Ch denies all other
        processes both read and write access to the locked region.
    11) For PC-MOS/386 native mode, use ECX and EDX instead of CX:DX.

Irv

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu