BBS: Inland Empire Archive
Date: 11-19-92 (11:47) Number: 335
From: TONY ELLIOTT Refer#: NONE
To: MARK THOMAS Recvd: NO
Subj: Re: Networking....Share Conf: (2) Quik_Bas
MT> When running on a network, I get a share violation. I tempoarily
MT> fixed the problem by creating duplicate files for every user, but
MT> as you can imagine this can be a pain when updating the files.
If you're running on a NetBIOS/Microsoft compatible network (Lantastic,
3COM, etc), and you wish to allow more than one user simultaneous
access to a given file, file "sharing" attributes must be set when you
open the file. For example:
OPEN "DATAFILE.DAT" FOR RANDOM ACCESS READ WRITE SHARED AS #1
As long as all of your users open the same file in this way, they will
all be allowed access at the same time. However, a new level of
complexity has just been introduced into the scheme. What happens if
two users try to access and update the same record at the same time?
Basic also supports the LOCK statement. For example, if you wish to
retrieve a record for updating, you need to LOCK it to prevent others
from accessing the same record at the same time:
LOCK #1, 20
GET #1, 20, RecVar
PUT #1, 20, RecVar
UNLOCK #1, 20
If you are retrieving the record for display or report purposes only
(e.g. you're not going to change it), there's no need to lock it.
A couple of things you have to keep in mind: For every LOCK there has
to be a matching UNLOCK. Basic will not automatically unlock all the
records your workstation locked if you should close the file or if your
program crashes. Leaving locks in place after either of these two
scenarios will cause (in MS's words) unpredictable results.
Also, you need to use BASIC's error trapping if you are going to use
locks. If you attempt to LOCK OR GET a record that's locked by someone
else, a BASIC error will be generated.
Also <g>, if you attempt to open a file using the ACCESS clause shown
above and SHARE.EXE is not loaded or if you're not on a network, an
error will result.
Something to keep in mind .. My company has a product called E-Tree
Plus. It's a multi-user database engine designed specifically for BASIC
that works on single-user and network systems, and takes cares of all
these nitty-gritty details for you. If you would like more info, let me
... To a cat, "NO!" means "Not while I am looking"
--- Blue Wave/Max v2.10 [NR]
* Origin: Oakland BBS - McDonough, GA - (404) 954-0071 (1:133/706.0)