Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Multi user unique file names?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00625605
Message ID:
00626079
Views:
17
Just use the SYS(2015) and check for the existance of the file before saving. If the file exists, do another call to SYS(2015). I usually use this method to generate PK's. The first try will almost always work. Frankly, I doubt the GUID is as 'universally unique' as MS claims it to be, either.

Here's the technique as used to generate a unique PK:
* Generate unique usercode
DO WHILE .T.
   lcUserCode = SUBSTR(SYS(2015), 3, 10)
   IF !INDEXSEEK(lcUserCode,.F.,'SystemUsers','UserCode')&& It's a good new key
      Exit
   ENDIF
ENDDO
>>Hi,
>>
>>>Is there a way to generate a unique file name in a multi user environment? I understand that Sys(2015) will do the job but if the file is to be saved to a network drive/share and two people go to create one at the same time, what is the outcome?
>>
>>Another option would be to use a WIN-API to generate a GUID (sth. like {12345-4567...}. You could use the GUID as the filename. GUIDs are unique in any case.
>>
>>If you're interested in a function to create GUIDs, I can post it here.
>>
>>Armin
>
>Armin,
>
>Thanks for the reply, is it just me or isn't this having to use a sledge hammer to crack a nut surely there must be a quick easy way of doing this?
>
>If not then your function would be greatly appreciated.
>
>Thanks
Kogo Michael Hogan

"Pinky, are you pondering what I'm pondering?"
I think so Brain, but "Snowball for Windows"?

Ideate Web Site
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform