Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Another wierd one
Message
 
À
07/03/2001 11:52:21
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00482754
Message ID:
00482856
Vues:
8
>I seem to be coming up with some strange things today...
>
>I have a select statement with a Nofilter command in it
>
>
>Select ;
>	prod_cd , ;
>	Alltrim(Str(ean_cd,14,0)) as ean_cd, ;
>	Alltrim(Str(var_num,2,0)) as var_num, ;
>	prod_grp, desc ;
>	FROM cur_prsr ;
>	ORDER BY prod_cd ;
>	INTO CURSOR pa_prsrch NOFILTER
>
>? File(dbf()) && Returns .F.
>
>
>This creates a cursor with no presence on disk...
>so I tried adding a Where .T. clause in...
>Still no luck
>
>I even looked with Explorer to see if the File() check was lying
>
>I thought this wasn't a problem any more?
>
>Win95 VFP6 SP4

Tell me about it...same thing on Win NT 4.0...I can regularly do the following:

select * from arapp0 into cursor cJoe nofilter && executes fine, creates cursor
? dbf('cJoe') && returns a temp file name, like C:\TEMP\77FJ09PA.TMP
? file(dbf('cJoe2')) && Returns .F. -- no real file presence.

I would be VERY interested to hear what is going on here.

BUT, I have found a way to make things work OK. I wrote a MAKEWRITABLE() function that always can take a cursor (with or without physical disk presence) and make it writable:

=================================================================
LPARAMETERS pcCursor

* This program takes a cursor and makes it writable by reusing the DBF()
* expansion of it. It will only do so for cursors where the DBF()
* is a TMP file (so make sure you use NOFILTER on the query that created the cursor
* to make sure the cursor truly exists as a temporary file on disk).
* RETURNS: TRUE if writable cursor is successfully created, FALSE otherwise.

* Check parameter
IF VARTYPE(pcCursor) <> 'C' OR EMPTY(pcCursor) OR NOT USED(pcCursor)
RETURN .F.
ENDIF
* Make sure cursor is truly a file...
IF OCCURS('.TMP',UPPER(DBF(pcCursor))) = 0
RETURN .F.
ENDIF

* Remember where we are...
lcWorkArea = ALIAS()

* If we made it here we can make the cursor writable. Use a temporary cursor
* with a unique name so that we don't overwrite anything in error
LOCAL lcTempCursor
lcTempCursor = 'c' + SYS(3)

USE DBF(pcCursor) IN 0 AGAIN ALIAS &lcTempCursor
USE IN (pcCursor)
USE DBF(lcTempCursor) IN 0 AGAIN ALIAS &pcCursor
USE IN (lcTempCursor)

* Return to proper work area
IF NOT EMPTY(lcWorkArea)
SELECT &lcWorkArea
ENDIF

RETURN .T.
=================================================================

Like I said, it seems to work whether or not a true gile is created (even though I say otherwise in the header comments). So, the magical line seems to be:

USE DBF(pcCursor) IN 0 AGAIN ALIAS &lcTempCursor

This seems to allow the name switch to another alias, though there STILL isn't a file presence for the new cursor name after this runs, at least not on my machine. Not sure what you are trying to do with your DBF(), but maybe this will help?

Good luck! I will be watching this thread!

JoeK
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform