Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I change dbc path in form
Message
From
11/10/2006 09:15:19
 
 
To
11/10/2006 05:40:09
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01160849
Message ID:
01161166
Views:
29
>PS: BTW I even didn't update that code yet for the better getpem() vs evaluate().

DraganN pointed me to this Fabio's trick :) (See thread and message#1135934)
I was using macrosubstitution before, so code was realy little ugly
duckling - but doing it's job for years :)
Here is how loop method ended up looking afterwards ;
define class oApp as custom
.
.
.
   procedure form_de
        lparameters oDataEnvironment
        local i,arr_obj(1),oDEO
        =amembers(arr_obj,oDataEnvironment,2)
        for i = 1 to alen(arr_obj)
            oDEO=getpem(oDataEnvironment, arr_obj(i))   
            if oDEO.BaseClass = 'Cursor'
               oDEO.database = this.get_database(justfname(oDEO.database))
            endif
        endfor


   procedure get_database
       lparameters cDbcNameOnly
       *
       * Run time path construction goes here 
       *        
       blah 
       blah
       *  
       return cFullPathAndDbcName


  
.
.
.
 
enddefine
Will add handling for free tables, and then see
if I can scramble deacent FAQ out of this.




>Cetin
>
>>The same here :)
>>
>>I don't understand why are you limiting this solution to only one app-path
>>or database at the time. Since you already hv global app object, then from within that cursor loop you can call method there passing just name of database and oApp.method can return full path.
>>
>>This way one form can use more then one databases at the same time and very reliably multiple SETS of databases (multiple companies for instance).
>>Whole point is letting oApp decide where each particular database is
>>at the time.
>>The same oApp method can be used when opening databases/tables via code.
>>
>>I hv seen/participated menu threads on this subject in past 7-8 years and always advised more less the same aproach. Unfortunately people are still boggled down with this issue, even after 10 years or more of VFP being arround.
>>(Recent one message#1135579)
>>
>>NOT having this issue effectively resolved can lead to variety of cripling designs, data mix-ups or even loss of valuable data - and consecutively
>>bad reputation to VFP.
>>
>>It wld be maybe good idea having FAQ entry about this.
>>
>>
>>
>>
>>>This is what I do:
>>>
>>>*UpdateDE.prg
>>>Lparameters toDE,tcAppDb,tcPath
>>>Do setups && contains general "set" like set century on, exact off, ...
>>>Local Array aDEMembers[1]
>>>Local lnMembers,ix,lcMembers
>>>if !(Type('oApp')='O' and !IsNull(oApp)) && in case testing with customer's data
>>>  public oApp
>>>  tcAppDb = iif(empty(m.tcAppDb),"mydefault.dbc", m.tcAppDb)
>>>  tcPath  = iif(empty(m.tcPath), "myDefaultDataFolder",m.tcPath)
>>>  oApp = CreateObject('myApp',m.tcAppDb,m.tcPath)
>>>endif
>>>lnMembers = Amembers(aDEMembers,toDE,2)
>>>For ix=1 To m.lnMembers
>>>	With Evaluate('toDe.'+aDEMembers[m.ix])
>>>		If Lower(.BaseClass) == 'cursor'
>>>			If Atc(oApp.cAppDBC,.Database) > 0
>>>				.Database = Addbs(oApp.cAppDataPath)+oApp.cAppDBC
>>>			Else
>>>				.CursorSource = Addbs(oApp.cAppDataPath)+Justfname(.CursorSource)
>>>			Endif
>>>		Endif
>>>	Endwith
>>>Endfor
>>>
>>>Define Class myApp As Custom
>>>	cAppDBC = ''
>>>	cAppDataPath=''
>>>	cCurPath = ''
>>>	Procedure Init(tcAppDb,tcPath)
>>>	  This.cCurPath = Set('path')
>>>	  This.cAppDataPath = m.tcPath
>>>          this.cAppDbc = (m.tcAppDb)
>>>	  set Path To (this.cAppDataPath+';'+This.cCurPath)
>>>	Endproc
>>>	Procedure Destroy
>>>	  Set Path To (This.cCurPath)
>>>	Endproc
>>>Enddefine
>>>
>>>* And I have this in DE.BeforeOpenTables
>>>UpdateDe(this)
>>>
Cetin
*****************
Srdjan Djordjevic
Limassol, Cyprus

Free Reporting Framework for VFP9 ;
www.Report-Sculptor.Com
Previous
Reply
Map
View

Click here to load this message in the networking platform