You can't do it in a global variable, or a global field, because those are user-specific. User A won't see user B's globals.
You'll need to do it either via a flag in a common table somewhere (a one-record table), or use a logging function to record the start / end of the script, and not allow a user to start the script if an open (i.e., start with no end) instance is present. You'll have to be very careful about this, though; if a user force-quits or otherwise gets kicked out (like because of a network interruption), you'll have the possibility of an open instance being indicated when none actually exists.
May I ask: What is the function that you want to restrict to exclusive processing? There may be another way to approach it.
Thanks Mike, useful info there. I know about the recovery position if a user fails to complete a script, and I can handle that.
Now why do want to do this?
I have a number of "counters" in the system, visible to the user that must maintain an unbroken series. I tried using FileMaker to do this automagically, but there were too many circumstance where I would end up with gaps in the sequence, so I developed scripts to obtain the next in sequence, and to allow numbers tp be returned to a pool and issued to the next requester if the user aborts a process. The problems appear where two users start working simultaneously.
On your first suggestion I already have a single record table in the system that can be used to hold the flags.
I would consider redo the script so that there is no way any kind of record looking would happen. If that is no option I always have a Global table with only one record that I can create a new field on that we can call Flag_ScriptName and that you do Set Field to "TimeStamp & UserName" in the beginning of the script and the you always check that field the first you do in the script and tell User 2 that this User is already running this script and started it TimeStamp. When User 1 finish script, last script step should be Set Field "".
I'm assuming you're referring to using auto-enter serial IDs, and the gaps that result when someone deletes a record. May I suggest that, instead of trying to cobble with scripting, you simply prohibit deletion of records?
Another source of gaps is when you clone the file and import records. This can be managed. Just make sure to reset the serial IDs using Set Next Serial Value.
Or is there another circumstance where gaps are a problem?
Johan is right about the record locking issue. You can't use a true "global" table (no fields that aren't globals), because, again, each user has his own set of globals, so if you do use a single-record table and two users attempt to get there at the same time, you'll get a record lock error (301).
I can’t remember the details now, but I know I worked on auto-enter Serial Ids, and there were other problems.
I don't know what the "counters" are and how crucial they are to the user at the time they're working with the data.
Maybe It would be an idea to have a temporary table that mimics the process and when the user is done just post the data to the actual table with a transactional script.
You can pretty much touch the related existing data that needs to be updated so you lock those records first.
Once you own them you can be sure to go on and create new records as needed, and commit in one go.
The nice thing is it runs quite fast ( record locking is reduced to minimum ), is reversible and totally under your control.
That approach has possibilities, thanks, I’ll look at that.