Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Temp files
Message
From
29/09/1997 22:08:41
Larry Long
ProgRes (Programming Resources)
Georgia, United States
 
 
To
29/09/1997 11:41:57
General information
Forum:
Visual FoxPro
Category:
FoxPro 2.x
Title:
Miscellaneous
Thread ID:
00051865
Message ID:
00052337
Views:
41
>Larry,
> I was NOT teh person in need of help on this one.. But, I have a question.. Isn't this a little overhead keeping track of all the Temp file names that your create?? Shouldn't these be nuked after a certain time??
>
>Also, I would think these files would go on a local drive, as apposed to a community directory that everyone writes to..
>
>
>The routine that I was thinking of was a one-two liner that combines SYS(3) and SYS(16) (Not sure on last one)..
>
>Thanx!
>
>Tony Miller
>vancouver, Wa

You can and should try to use the temp cursors as much as possible. But for those situations where you need a semi-permanent temp file I have found UNIQFILE.PRG to be the most flexible. You are right in that temp files should reside on local drives, but not everyone has a local hdd, and UNIQFILE.PRG handles those problems. How about this...

UNIQFILE.PRG (needs a dummy dbf called UNIQTEST.DBF)
-------------------------

PARAMETERS PREFIX,EXT
* Author: Larry Alan Long / Copyright 1997, All rights reserved.
* Freeware, you may distribute, use and modify this code as you see fit. Just keep the comment section intact along with
* documenting any changes that you have added.
*
* Parameters - PREFIX - For naming your temp files with a specified prefix. I use this so you can track where the temp files
* come from if your app does not clean up properly after itself and you wind up with temp
* files cluttering up your system.
* - EXT - For naming your temp file's extension
*
* For example, I would use UNIFILE('RIX','TMP') to create a temp file called RIX00001.TMP, for my reindexing routine.
*
********
* 09/28/97 - LAL - ADDED THE USE OF "TMPFILPATH" VARIABLE. DECLARE THIS VARIABLE PUBLIC IN YOUR START UP *PROGRAM OR SAVE IT TO A MEMORY FILE AND RESTORE IT (ADDITIVE) UPON STARTUP TO USE A SPECIFIED *LOCATION FOR YOUR TEMP FILES CREATED BY THIS ROUTINE
*
IF EMPTY(PREFIX)
STORE SPACE(0) TO PREFIX
ENDIF

IF EMPTY(EXT)
STORE "TMP" TO EXT
ENDIF

STORE ON('ERROR') TO olderrproc

ON ERROR DO UNIQERR

*To prevent a possible duplicate, UNIQTEST.DBF is a dummy dbf that is used to ensure that only one
* UNIQFILE is generated at a time.

USE UNIQTEST EXCLUSIVE IN 0

ON ERROR &olderrproc

STORE 1 TO TRIES

if type('TMPFILPATH')='U'
*FOR EXAMPLE TMPFILPATH COULD BE "C:\TEMP\"
store space(0) to tmpfilpath
endif

DO WHILE TRIES<=100

STORE tmpfilpath+PREFIX+RIGHT(SYS(3),8-LEN(PREFIX))+'.'+EXT TO UNIQFILE

IF ! FILE(UNIQFILE)
XX=FCREATE(UNIQFILE)
=FCLOSE(XX)
EXIT
ENDIF

STORE TRIES+1 TO TRIES
ENDDO

USE IN UNIQTEST


IF TRIES>100
WAIT WINDOW 'TOO MANY TRIES. SOMETHING IS WRONG!'
RETURN(.F.)
ENDIF

RETURN(UNIQFILE)

PROCEDURE UNIQERR
WAIT WINDOW "WAITING FOR PROCESS TO BE RELEASED BY ANOTHER" TIMEOUT 1
WAIT CLEAR
RETRY
L.A.Long
ProgRes
lalong1@charter.net
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform