Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SET commands and private datasessions... 2

Status
Not open for further replies.

thatguy

Programmer
Aug 1, 2001
283
US
Hey there folks..

I'm looking for ideas on how to handle setting those SET commands that are scoped to the current datasession (specifically DELETED). I use a global environment object created by the main app object to set all those vars, but my forms all use private data sessions. So I'm thinking about creating a separate env object in each form's Load event (form.Oformenv = createobject...). Has anyone else tried this? Pros/Cons? Know of some better way?

Thanks
-- michael~
 
Michael,
Open the Data envronment (DE) on your form. In the method "Before Open Tables" put in this:

SET TALK OFF
SET DELETED ON

Or whatever other SET commands you need. Apparently in VFP8, you can now establish a forms DE as an inheritable object, but in VFP7 and prior, you have to set each form's DE individually.

Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
You can grab all your settings by doing this:

Select Tools->Options from the mainmenu.
Hold the Shift key down and click Ok

All your settings will now be in the command window. Cut and paste into your Init method and you will have the same 'SET's.
Dave S.
 
michael,
Why not simply create your own form base class? That way you only need to put your defaults in one place and you can always override any of them in the forms you create based on it.

Rick
 
hmm.. well, I Do have a form base class. Are you saying to include props for every env var? Or set them all in the base init()? Or owuld it be better to put them in the Load()?

-- michael~
 
michael,
In reallity, I put them in a user method in my base form class, and then call that method from my LOAD(). Having it as a separate method allows me to reset these from anywhere in the form if necessary.

Rick
 
Rick,
Now that's a clever idea... Star for that one. Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Sounds like that'll work. And if I need any subclassed form to have any particular env var changed from the "default" base class's, in the user method of the subclass, I'd put:

DODEFAULT
SET DELETED OFF

Right?

-- michael~
 
michael,
Correct. Although I usually write it like:
Code:
IF !DoDefault()
   RETURN .F.
ENDIF
SET DELETED OFF
That way if you have any code in your base class that may cause you to want to abort the LOAD(), you'll handle this passed up information properly.

Rick


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top