Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Cycle though tables in DataEnviornment
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00314653
Message ID:
00314955
Vues:
20
Nick,
>>
>> I'm not sure, that I understand, how can we take it of from the loop. It evaluates loObj depending on laCursorList[i]...

May be I'm still missing something, but what happens, if we have several databases in DE? It is possible, isn't it?


>
>Like this: :)
>
>*- loop thru cursors and replace database name with correct database to use -*
>IF ALEN( laCursorList,1) > 0
>FOR I = 1 TO ALEN(laCursorList,1)
>loObj = EVAL("Thisform.DataEnvironment." + laCursorlist[i])
>IF UPPER(loObj.BASECLASS) = 'CURSOR' AND '\' $ loObj.Database
>IF NOT EMPTY(loObj.Database)
>*- table in database -*
>loObj.Database = oApp.gcDbPath + oApp.gcDbName
>ELSE
>*- free table -*
>loObj.CursorSource = oApp.gcDbPath + oApp.gcDbName
>ENDIF
>ENDIF
>NEXT
>
>	IF NOT DBUSED(loObj.Database)
>		OPEN DATABASE (loObj.Database)
>	ENDIF
>	SET DATABASE TO (loObj.Database)
>

>ENDIF
>
>When we go out of the loop, loObj still contains the last processed object in the Dataenvironment. However, this may not work properly if the last object in DE is a Relation which has no .Database property.
>My concern is only to OPEN/SET DATABASE once, and it can be done different ways, for example through adding a local variable llSetDatabase which will take care of this inside existing code:
>
>
*- loop thru cursors and replace database name with correct database to use -*
>IF ALEN( laCursorList,1) > 0
>	LOCAL llSetDatabase
>	llSetDatabase = .t.
>	FOR I = 1 TO ALEN(laCursorList,1)
>		loObj = EVAL("Thisform.DataEnvironment." + laCursorList[i])
>		IF UPPER(loObj.BASECLASS) = 'CURSOR' AND '\' $ loObj.Database
>			IF NOT EMPTY(loObj.Database)
>				*- table in database -*
>				loObj.Database =  oApp.gcDbPath + oApp.gcDbName
>				IF llSetDatabase = .t.
>					IF NOT DBUSED(loObj.Database)
>						OPEN DATABASE (loObj.Database)
>					ENDIF
>					SET DATABASE TO (loObj.Database)
>					llSetDatabase = .f.
>				ENDIF
>			ELSE
>				*- free table -*
>				loObj.CursorSource = oApp.gcDbPath + oApp.gcDbName
>			ENDIF
>		ENDIF
>	NEXT
>ENDIF
>


BTW, Jim Booth wrote me, that if we have logical variable, we don't need to write : if llVar=.t., because it's the same to write if llVar. It will count only in SQL optimization...

Nadya
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform