Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Table not closing
Message
From
09/06/2016 08:11:34
 
 
To
08/06/2016 20:11:05
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01637157
Message ID:
01637171
Views:
77
>>I have a weird, and persistent problem. A free table that doesn't want to close. Here is code:
>>
>>
>>IF mwebenable	
>>	thiswebfile=&mwebpath+'jobsweb.dbf'
>>	thiswebfile1=&mwebpath+'applweb.dbf'
>>	USE &thiswebfile1 IN 0
>>	SELECT applweb
>>	SET ORDER TO 1 
>>	IF !USED('&thiswebfile')
>>		USE &thiswebfile IN 0
>>	ENDIF 
>>	SELECT jobsweb
>>	SET ORDER TO 1
>>	SEEK mponum
>>        ....
>>        ....
>>	SELECT applweb		
>>	USE IN applweb
>>	SELECT jobsweb
>>	USE IN jobsweb
>>ENDIF
>>
>>
>>NO problems with 'applweb.bdf' at all, but run the prg more than once, and 'jobsweb.dbf' comes up unclosed. And I have tried all combos of Select and Use that I can think of.
>>
>>I can't use 'close tables all', as that will close the stuff in the DE, too, which is NOT wanted.
>>
>>What else can I do? ANY ideas will be greatly appreciated!
>
>The use of & macro expansion is bug prone, it will fail if a path contains a space. I'd refactor to use named expressions e.g.
>
>* Get used to using the m. prefix for memory variables
>* so there's no chance of a memvar name conflicting with a column name in a open table
>m.mWebPath = "C:\Some \Path \With \Spaces"
>
>* You'll often want to use ADDBS( ), which will add a trailing backslash if not already present
>* With that you can
>USE ( ADDBS( m.mWebPath ) + "JobsWeb.dbf" ) IN 0
>
Actually, better than ADDBS() here is FORCEPATH(). Just let the engine do the construction:
USE (ForcePath("JobsWeb.DBF", m.mWebPath)) IN 0
Tamar
Previous
Reply
Map
View

Click here to load this message in the networking platform