Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Question about File() fundtion
Message
From
02/04/2004 19:17:05
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00891861
Message ID:
00891941
Views:
16
Steve,

>I have a routine that needs to create a series of random files but make sure
>that each one is unique. But each time I test for uniquesness with if File(thisFileName),
>it takes some time to check the disc drive. Therefore, should I include a brief wait period
>before or after checking for each file?

Steve, I suggest using the Windows API to generate your random file names which will be guaranteed unique. I've got an example here on the files section: http://www.levelextreme.com/wconnect/wc.dll?FournierTransformation~2,2,9773, but here's the relevant part.
  PROCEDURE GetUniqueFile( tcPrefix )
  *!* This method creates a file with a .TMP extension in the system temporary directory
  *!* Returns the fully qualified path including file name.
  *!*
  *!* Pass a 3-character prefix to use for the temporary file names
  *!*
  DECLARE LONG GetTempFileName IN "kernel32" ;
  STRING lpszPath, ;
  STRING lpPrefixString, ;
  LONG wUnique, ;
  STRING lpTempFileName

  WITH THIS
    LOCAL lnReturn, lcTmpPath, lcTmpName, lcPrefix
    lcPrefix = IIF( EMPTY( tcPrefix ), "UNK", tcPrefix )
    lcTmpName = REPLICATE( ' ', 576 )
    lcTmpPath = .GetPath()
    lnReturn = GetTempFileName( lcTmpPath + .LastSubdir, lcPrefix, 0, @lcTmpName )
    .LastFile= lcTmpName
    .LastPrefix = lcPrefix
  ENDWITH
  RETURN STRTRAN( lcTmpName, CHR(0), '' )
  ENDPROC
Previous
Reply
Map
View

Click here to load this message in the networking platform