File locking

 BBS: Inland Empire Archive
Date: 01-16-93 (14:04)             Number: 332
From: MATT HART                    Refer#: NONE
  To: WES GARLAND                   Recvd: NO  
Subj: File locking                   Conf: (2) Quik_Bas
 WG>   I have a question, and I need it answered, quite badly. How
 WG> can I find out if a file is already locked by another task on my
 WG> system???

If you try to GET or open it and can't - with ON ERROR
checking.  You can use this in a FUNCTION:

'Untested
     DEFINT A-Z

     ON ERROR GOTO L.Error

FUNCTION Locked(File$)
     SHARED Ecode
     Ecode = 0
     F = FREEFILE
     OPEN File$ FOR BINARY AS F
     IF Ecode THEN Locked = -1 : EXIT FUNCTION
     CLOSE F
     Locked = 0
END FUNCTION

L.Error:
     Ecode = -1
     RESUME NEXT
---
 * Origin: Midnight Micro!  V.32/REL  (918)451-3306 (1:170/600)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET