Announcement

Collapse

New Sub-Forum

In an effort to help make sure there are appropriate categories for topics of discussion that are happening, there is now a sub-forum for databases and database programming under Special Interest groups. Please direct questions, etc., about this topic to that sub-forum moving forward. Thank you.
See more
See less

File locking

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • File locking

    As far as I can tell from the PB 3.5 manual, there are two
    distinct ways to lock a file, as below:

    open "myfile.dat" for binary as 1
    lock 1

    or:

    open "myfile.dat" for binary lock read write as 1

    The first one requires the file to be unlocked before closing the
    file, but the book says nothing about unlocking the file if the
    second method is used. Does the second way require unlocking,
    or as it appears, the unlocking is automatic with the close
    statement?

    TIA, Colin.

    ------------------

  • #2
    The CLOSE statement automatically takes care of unlocking the file, in accordance with the lock mode in the OPEN..LOCK statement.

    If you explicitly use the LOCK statement (to lock records, bytes or a complete file), you *must* explicitly UNLOCK those portions before closing the file.

    I hope this helps!


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      Thanks, Lance. The book doesn't actually say so, and I'd sooner be sure than sorry.
      Colin

      ------------------

      Comment

      Working...
      X