>Hi all,
>
>
>I'm trying to fit some extra network functionality to my program.
>I know it is standard implemented, but.....
>
>- the location of the tables should be variable
>(some user have a 'H-drive' others have an 'M-drive', ....)
>When you use the wizards then the location of the tables is stored in the environment. I've tried to change it via some code but .... it did'nt work.
>
>Any suggestions ??
>It's rather urgent
>Marc
Marc,
One way is to call a routine from the BeforeOpenTables method of the DataEnvironment to adjust the references to the tables. I use the routine below to allow the use of a standard set of forms and reports with multiple applications. It changes the Database or CursorSource property to match the application's database. With a few changes it can handle your drive letter problem. This routine assumes the default directory is WORK and the data is in ..\DATA. oApp,cDatabase is a property of the application object that contains the name of the database. You won't need this if all you want to do is adjust the drive letter.
LPARAMETERS toDataEnvironment
LOCAL lcDataDir && Appplications data directory
LOCAL laMembers[1] && DE members array
LOCAL lnObjectCount && Number of objects in DE
LOCAL lnI && Loop index
LOCAL lcObjectName && Object name string
LOCAL lcTableName && Name of free table
LOCAL lcCursorSource && Cursorsource property of cursor
lcDataDir = SET("DEFAULT")+LEFT(CURDIR(),RAT("\",CURDIR(),2)) + "Data\"
lnObjectCount = AMEMBERS(laMembers, toDataEnvironment, 2)
FOR lnI = 1 to lnObjectCount
lcObjectName = laMembers[lnI]
IF UPPER(toDataEnvironment.&lcObjectName..BaseClass) = "CURSOR"
IF NOT EMPTY(toDataEnvironment.&lcObjectName..Database)
* Bound table - Update Database property
toDataEnvironment.&lcObjectName..Database = ;
lcDataDir + oApp.cDatabase + ".DBC"
ELSE
* Free Table - Update CursorSource property
lcCursorSource = toDataEnvironment.&lcObjectName..CursorSource
lcTableName = SUBSTR(lcCursorSource, RAT("\", lcCursorSource)+1)
toDataEnvironment.&lcObjectName..CursorSource = ;
lcDataDir + lcTableName
ENDIF
ENDIF
ENDFOR