It's the way it is, VFP9 requires exclusive access for indexing. The only way the same code works in VFP9 is when SET('EXCLUSIVE') is 'ON'.
It's clear you SET EXCLUSIVE OFF for shared access, but it's one of the settings specific to sessions. OFF by default in EXE or vfp9r.dll, ON by default in the IDE. The idea behind that difference is the IDE is for developers who need exclusive access more than not and an EXE for multi-users needs shared access.
I can only second the thought of Mike, your architecture is worth rethinking. And since you skip from version 6 to 9 that means you now have to do the work ALL AT ONCE that you could have done gradually over 20 years. I'm not really compassionate about that.
The decision was made to need exclusive access, even for the first index of a CDX, creating it because it's not just a matter of this new file, you also read the DBF while creating the CDX, in the past that could have meant users writing to parts of the DBF already in the CDX will mean the CDX finally created is already out of sync with the DBF. Not in the case of an empty DBF just created, but in case of a large DBF frequently used shared.
Once the CDX already exists and is the main CDX the DBF handling automatically also updates with DBF updates, that's possible in shared mode. That's done the usual way by having a short span of automatic locking as with all write operations. But in that first full table scan of the CDX tag generation process, you process ALL records. And that's better done exclusively for that reason.
That's a not downward compatible change of VFP9. Get over it, there are some such changes and they mean you have to change your code, YES! Absolutely, for the better.
You THINK you've seen a gap in this where the downward compatibility is given, but I'm sure there isn't. You just had cases in which EXCLUSIVE is ON, that's all. SET EXCLUSIVE ON clearly is not your solution, so it is looking for USE after CYOP STRU and making them EXCLUSIVE, Index, then USE the final DBF with CDX shared again and continue. Notice there also is COPY STR WITH CDX now. And even the old way, it is quite impossible you get a problem accessing the newöy created DBF exclusively, as your user session is the only one knowing of it as of now.
Besides, it's questionable an application needs copies if table structures. For the 3GB limit? Or for monthly/yearly data? You could have changed to MSSQL backend over the past 20 years.
Being lazy about something for 20 years means you now have to be busy for a while. What do you do if you have a task that is a dull repetition of work for 1000s of times? You write a program doing that. Source code is text and VFP has string functions. If you don't see it that way, this makes me wonder a bit, but I don't start getting into assumptions.
Even better think of a way not needing all these table copies. It's really a bad construct.
And what's worse is insisting on downward compatibility where there is a good reason for the new rule of the advanced Foxpro language. You go with it.
Bye, Olaf.
Olaf Doschke Software Engineering