C+ C NAME: C iUniqueName C PURPOSE: C Construct unique file name C CATEGORY: C String handling C CALLING SEQUENCE: function iUniqueName(cPattern,cFile) C INPUTS: C cPattern character*(*) Should contain a single or two question marks C OUTPUTS: C cFile character*(*) Unique file name C iUniqueName integer value of itrim(cFile) C CALLS: C iGetFileSpec, iSetFileSpec, iPutFileSpec, itrim, cTime2System C INCLUDE: include 'filparts.h' C SIDE EFFECTS: C If no question marks are present then cPattern is interpreted as C a fully qualified file name, and the number is inserted after the C file name part. C PROCEDURE: C > The file name is constructed by replacing the question mark in the C string cPattern by an eight or ten digit number. The number is C constructed from the system time (6 or 8 digits) and a counter C (2 digits). C > If the pattern contains '??', then the '??' will be replaced by a C 10 digit number. C > If the pattern contains '?', then the '?' will be replaced by an C 8 digit number. If the pattern specified is of the form '?.DAT', then C the resulting file name will be a valid DOS file name. C MODIFICATION HISTORY: C 1991, Paul Hick (ARC, UCSD/CASS; pphick@ucsd.edu) C- character cFile*(*) character cPattern*(*) character cSave*(FIL__LENGTH) character cTime2System*80 integer getpid logical bFirst /.TRUE./ save bfirst iiQ = index(cPattern,'?') ! Position of '?' if (iiQ .eq. 0) then ! No '?' I = iGetFileSpec(0,0,cSave) I = iSetFileSpec(cPattern) I = iGetFileSpec(FIL__NAME,FIL__NAME,cFile) cFile(I+1:) = '?' else cFile = cPattern end if iQ = index(cFile,'?') cFile(iQ+14:) = cFile(iQ+1:) ! Make room for insert cFile(iQ:iQ+5) = cTime2System('hhmmss')! Get system time if (bFirst) then write (cFile(iQ+6:iQ+13),'(I8.8)') nint(rand(getpid())*1e8) bFirst = .FALSE. else write (cFile(iQ+6:iQ+13),'(I8.8)') nint(rand(0 )*1e8) end if iUniqueName = itrim(cFile) if (iiQ .eq. 0) then I = iPutFileSpec(FIL__NAME,FIL__NAME,cFile) I = iGetFileSpec(0,0,cFile) I = iSetFileSpec(cSave) end if return end