Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CursorSource in DataEnvireonment
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00252319
Message ID:
00252820
Views:
8
Hi Doug

After studying the code it occurred to me that you are directly editing the CursorSource of the View/Table in the DataEnvireonment. All my tables are free tables, the subdirectory is in a memory variable, and I will know the names of the cursors in the data envireonment, why not just write code to directly modify the CursorSource just before calling the Form?

My major concern was that the Help screen for the CursorSource says it is Read-only at design time and read-write at run time.

I would like to have the CursorSource change at design time. Why would your code accomplish this objective? If it doesn't, can I write code to modify the SCX file directly to modify this? The subdirectory must be buried somewhere.

And how can the program detect whether it is running run-time or development? I can't find a function that tells the program this.

Thanks
Bruce


>Hi Bruce.
>
>>In my application the database opened could be in one of many company subdirectories, so the path cannot be specfied ahead of time.
>
>Here's what I do:
>
>- Set the AutoOpenTables of the DataEnvironment to .F. so it doesn't automatically open the tables.
>
>- Put the following code into the Load method of my form base class:
>
>
>with This
>  do case
>    case type('.DataEnvironment') <> 'O' or ;
>      .DataEnvironment.AutoOpenTables
>    case type('oApp.Name') = 'C' and ;
>      pemstatus(oApp, 'SetDataDirectory', 5)
>      oApp.SetDataDirectory(.DataEnvironment)
>      .DataEnvironment.OpenTables()
>    otherwise
>      .DataEnvironment.OpenTables()
>  endcase
>endwith
>- My application object (instantiated into oApp) has the following code in its SetDataDirectory method:
>
>
lparameters toDE
>local laObjects[1], ;
>  lnObjects, ;
>  lcDirectory, ;
>  lcCommon, ;
>  lnI, ;
>  loObject, ;
>  lcDatabase, ;
>  lcTable
>
>* Get a list of the members of the DataEnvironment, and get
>* the data directory from the cDataDir property.
>
>lnObjects   = amembers(laObjects, toDE, 2)
>lcDirectory = This.cDataDir
>
>* Look at each member object, but only process cursors.
>
>for lnI = 1 to lnObjects
>  loObject = evaluate('toDE.' + laObjects[lnI])
>  if upper(loObject.BaseClass) = 'CURSOR'
>    lcDatabase = loObject.Database
>
>* If this is a free table, adjust the CursorSource property.
>
>    if empty(lcDatabase)
>      lcTable = loObject.CursorSource
>      loObject.CursorSource = lcDirectory + ;
>        substr(lcTable, rat('\', lcTable) + 1)
>
>* This cursor is part of a database, so change the database property.
>
>    else
>      loObject.Database = lcDirectory + ;
>        substr(lcDatabase, rat('\', lcDatabase) + 1)
>    endif empty(lcDatabase)
>  endif upper(loObject.BaseClass) = 'CURSOR'
>next lnI
>
>- oApp also has a property, cDataDir, which contains the directory for the current data set.
>
>Of course, you can adapt this to your own needs: SetDataDirectory can exist in some other object or even be a standalone PRG.
>
>Doug
Bruce Strom

Prayer of St Ephrem:
O Lord and Master of My Life,
Take from me the spirit of sloth, meddling, ambition and vain talk.
But give me a spirit of prudence, humility, patience and love.
Yes Lord and King grant me to see my own sins and faults
and not judge my brother.
For You are Blessed Forever and Ever. Amen.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform