>Hi Friends ,
>
>This time behaviour dataenviron is hurting me...ha ha ha
>
>when i move my project from developement pc to user's site. Dataenvironment gives me errors regarding tables path.
>
>When u add a table in a dataenvironment, it automatically stores the path for that table. But software can be installed at different location in user's pc.
>
>How to handle this issue.
>
>
>Pleas Help
>Sunny
There are few ways to do this
we have global object app in the program based on custom class
and it has method clearpath, we call it in before table open in the dataenvironment
Here is the code of this method
lparameters oThis
if type('this.aDataPath[1,1]') = 'L'
local ch, cName, cb, nCnt
nCnt = 0
cName = this.bazaname
DO WHILE .T.
ch = AT(";",cName)
IF ch > 0
cb=SUBSTR(cName,1,ch-1)
if file(cb + '.DBC')
nCnt = nCnt + 1
dimension this.aDataPath[nCnt,3]
this.aDataPath[nCnt,1] = upper(substr(cb,rat('\',cb)+1) + '.dbc')
this.aDataPath[nCnt,2] = upper(cb + '.dbc')
this.aDataPath[nCnt,3] = upper(left(cb,rat('\',cb)-1))
endif
ELSE
EXIT
ENDIF
cName=SUBSTR(cName,ch+1)
ENDDO
endif
if type('oThis') # 'O'
return
endif
local i, obj, nMember, aCursor[1], cDbc, j, nPos
nMember = amembers(aCursor,oThis,2)
for i = 1 to nMember
if 'CURSOR' $ aCursor[i]
obj = eval('oThis.' + aCursor[i])
if type('obj') # 'U' .and. upper(obj.baseclass) = 'CURSOR'
cDbc = upper(substr(obj.database,rat('\',obj.database)+1))
for j = 1 to alen(this.aDataPath,1)
if this.aDataPath[j,1] == cDbc
nPos = j
exit
endif
endfor
obj.database = this.aDataPath[nPos,2]
endif
endif
endfor
The main program read config.fpw , where we have the path to real database
and makes set path to this.datapath
Than just in VFP at any data location program works with the right data location
2 Second method
To have global variable with the datapath
Open all forms like tables , looks records with cursors and change specific pathes on this global variable
For example, cursor was like this c:\proj\data\goods.dbf
Became m.path+goods.dbf
MVP-2006-2011, PHD in Math and Physics ,
host of
www.foxclub.ru,
VFP lector at Interface and Microinform companies
Head science researcher of VNIIA Rosatom.