* Use to fix the path for a table
* expC1 Name of the cursor we have to modify
* expC2 Alias (if passed will override the default cursor alias)
LPARAMETER tcCursor,tcAlias
LOCAL lcObject
lcObject="ThisForm.DataEnvironment."+tcCursor
WITH &lcObject
SELECT TABLE
* We will locate for record in TABLE.DBF
IF NOT EMPTY(tcAlias) AND TYPE('tcAlias')='C'
* We need to replace the Alias and the CursorSource properties
* because we will override the cursor
SEEK UPPER(ALLTRIM(tcAlias)) ORDER ALIAS
STORE tcAlias TO .Alias
STORE ALLTRIM(NOM) TO .CursorSource
ELSE
* If this is a view
IF UPPER(.CursorSource)='VIEW'
LOCAL lcDatabase
lcDatabase=SUBSTR(.Database,RAT('\',.Database)+1)
STORE oApp.cData+'\'+lcDatabase TO .Database
RETURN
ENDIF
LOCAL lcAlias,lnAt
lcAlias=SUBSTR(.CursorSource,RAT('\',.CursorSource)+1)
lnAt=AT('.',lcAlias)
IF lnAt>0
lcAlias=SUBSTR(lcAlias,1,AT('.',lcAlias)-1)
ENDIF
=SEEK(UPPER(lcAlias),'TABLE','ALIAS')
ENDIF
* We will replace the database property for those that are in a DBC
IF NOT EMPTY(DBC)
IF oApp.lMainIni
STORE oApp.cData+'\'+ALLTRIM(DBC)+'.dbc' TO .Database
ELSE
STORE ALLTRIM(DBC)+'.dbc' TO .Database
ENDIF
ELSE
* We will replace the CursorSource property with the full path
* for those not part of a DBC
STORE ALLTRIM(CHEMIN)+'\'+ALLTRIM(NOM)+'.dbf' TO .CursorSource
* If we are in a pick list or in a grid admin
* Because of a bug in Visual FoxPro 5, we are not allowed
* anymore to set the property of Database to blank
* This means we will use a technique to add a cursor here
* in order to have it blank at first
IF ThisForm.Name='recherche'
ThisForm.DataEnvironment.RemoveObject('Cursor1')
ThisForm.DataEnvironment.AddObject('Cursor2','Cursor')
ThisForm.DataEnvironment.Cursor2.CursorSource=ALLTRIM(CHEMIN)+'\'+ALLTRIM(NOM)+'.dbf'
ThisForm.DataEnvironment.Cursor2.Alias=ALLTRIM(NOM)
ThisForm.DataEnvironment.Cursor2.BufferModeOverride=2
ThisForm.DataEnvironment.InitialSelectedAlias=ALLTRIM(NOM)
ENDIF
* We need to remove the database
* .ResetToDefault('Database')
ENDIF
* If we are in adding mode, we have to change the buffering property to optimistic
* to have the possibility to create more than one record at a time for this form
IF TYPE('oApp.nRecnoToProcess')='N' AND oApp.nRecnoToProcess=-1
STORE 5 TO .BufferModeOverride
ENDIF
ENDWITH