EnvLib is a collection of classes that you can use (and aggregate) to save and restore your environment. The classes save, set, and restore SET, ON, open table, system variable, object properties, and other helpers.
The original version of EnvLib for Visual FoxPro was created by Tom Rettig in July 1995. Tom passed away in February 1996. Since then Visual FoxPro has moved forward significantly. This is an updated version of his original library.
- Over 120 lightweight classes, one for each aspect of the Visual FoxPro environment.
- Objects save, and optionally set, aspects of the VFP environment upon
init()
. - Objects restore their aspect of the VFP environment upon
destroy()
. - Therefore facets of the VFP environment are automatically reset when objects go out of scope.
- Objects can be nested at design-time or run-time to group many aspects into one object.
- Objects can be configured at creation-time to not reset upon
destroy()
.
To include Envlib in your application, simply call SET PROCEDURE ... ADDITIVE
prior to using it.
SET PROCEDURE TO <path>\EnvLib ADDITIVE
In standard Visual FoxPro, saving and setting SET PATH
looks something like this:
LOCAL lcAPath
lcPath= SET( "path" )
SET PATH TO newPath && or SET PATH TO newPath ADDITIVE
* Lots of code here
* Now restore the previously selected work area
SET PATH TO &lcPath && Do this everywhere you might exit
RETURN
With Envlib, you do this:
LOCAL loAlias
loAlias= CREATEOBJECT( "SetPath", "newPath" )
* or loAlias= CREATEOBJECT( "SetPath", "newPath", "Additive" )
* Lots of code here
RETURN
Note you don't need to cover every exit point because when lcPath
goes out of lexical scope, SET PATH
is reset upon its destroy.
In standard Visual FoxPro, saving the current work area looks something like this:
LOCAL lcAlias
lcAlias= SELECT()
* Lots of code here
* Now restore the previously selected work area
SELECT ( lcAlias ) && Do this everywhere you might exit
RETURN
With Envlib, you do this:
LOCAL loAlias
loAlias= CREATEOBJECT( "SaveSelect" )
* Lots of code here
RETURN
Note you don't need to cover every exit point because when loAlias goes out of lexical scope, the work area is reset upon its destroy.
LOCAL lcAlias
lcAlias= SELECT()
SELECT Customer
* Lots of code here
* Now restore the previously selected work area
SELECT ( lcAlias ) && Do this everywhere you might exit
RETURN
With Envlib, you do this:
LOCAL loAlias
loAlias= CREATEOBJECT( "SetSelect". "Customer" )
* Lots of code here
RETURN
Class | Parent | Notes |
---|---|---|
Set | Custom | Abstract class |
SetTwo | Set | Abstract class |
SetOnOff | Set | Abstract class |
SetOnOffTwo | SetTwo | Abstract class |
On | Custom | Abstract class |
SaveArea | Custom | Abstract class |
SaveUsedArea | SaveArea | Abstract class |
These classes save, set, and restore the various VFP SET
commands that have corresponding SET()
functions.
Class | Parent |
---|---|
SetAlternate | SetOnOffTwo |
SetAnsi | SetOnOff |
SetAsserts | SetOnOff |
SetAutoIncError | SetOnOff |
SetAutosave | SetOnOff |
SetBell | SetOnOff |
SetBlocksize | Set |
SetBrstatus | SetOnOff |
SetCarry | SetOnOff |
SetCentury | SetOnOff |
SetClassLib | Set |
SetClear | SetOnOff |
SetClock | SetOnOff |
SetCollate | Set |
SetCoverage | Set |
SetColor | Set |
SetCompatible | SetOnOffTwo |
SetConfirm | SetOnOff |
SetConsole | SetOnOff |
SetCpcompile | Set |
SetCpdialog | SetOnOff |
SetCurrency | SetTwo |
SetCursor | SetOnOff |
SetDatabase | Set |
SetDataSession | Set |
SetDate | Set |
SetDebug | SetOnOff |
SetDecimals | Set |
SetDefault | Set |
SetDeleted | SetOnOff |
SetDelimiters | SetOnOffTwo |
SetDevelopment | SetOnOff |
SetDisplay | Set |
SetDohistory | SetOnOff |
SetEcho | SetOnOff |
SetEngineBehavior | Set |
SetEscape | SetOnOff |
SetExact | SetOnOff |
SetExclusive | SetOnOff |
SetFdow | Set |
SetFixed | SetOnOff |
SetFullPath | SetOnOff |
SetFweek | Set |
SetHeadings | SetOnOff |
SetHelp | SetOnOffTwo |
SetHelpfilter | Set |
SetHours | Set |
SetIntensity | SetOnOff |
SetKeycomp | Set |
SetLibrary | Set |
SetLock | SetOnOff |
SetLogErrors | SetOnOff |
SetMargin | Set |
SetMackey | Set |
SetMark | Set |
SetMemoWidth | Set |
SetMessage | SetTwo |
SetMultiLocks | SetOnOff |
SetNear | SetOnOff |
SetNotify | SetOnOff |
SetNull | SetOnOff |
SetNullDisplay | Set |
SetOdometer | Set |
SetOLEObject | SetOnOff |
SetOptimize | SetOnOff |
SetPalette | SetOnOff |
SetPath | Set |
SetPrinter | SetOnOffTwo |
SetPoint | Set |
SetProcedure | Set |
SetReadBorder | SetOnOff |
SetRefresh | SetTwo |
SetReprocess | Set |
SetResource | SetOnOffTwo |
SetResourceCreate | SetResource |
SetSafety | SetOnOff |
SetSeconds | SetOnOff |
SetSeparator | Set |
SetSpace | SetOnOff |
SetStatus | SetOnOff |
SetStatusBar | SetOnOff |
SetStep | SetOnOff |
SetSysFormats | SetOnOff |
SetSysMenu | Set |
SetTableValidate | Set |
SetTalk | SetOnOff |
SetTopic | SetTwo |
SetTrBetween | SetOnOff |
SetTypeahead | Set |
SetUdfParms | Set |
SetUnique | SetOnOff |
SetView | SetOnOff |
SetWindowOfMemo | Set |
SetVfpDefaults | Custom |
These classes save, set, and restore the various VFP ON
commands that have corresponding ON()
functions.
Class | Parent |
---|---|
OnError | On |
OnKey | On |
OnKeyLabel | On |
OnShutDown | On |
These classes save, set, and restore the various aspects of saving the properties of work areas.
Class | Parent |
---|---|
SaveSelect | SaveArea |
SetSelect | SaveSelect |
SaveBuffering | SaveUsedArea |
SetBuffering | SaveBuffering |
SaveRecno | SaveUsedArea |
SaveOrder | SaveUsedArea |
SetOrder | SaveOrder |
SaveFilter | SaveUsedArea |
SetFilter | SaveFilter |
SaveRelation | SaveUsedArea |
SetRelation | SaveRelation |
SaveTable | SaveUsedArea |
SaveAllTables | Custom |
OpenAliasCheckpoint | Custom |
These classes save, set, and restore various other things.
Class | Parent | Notes |
---|---|---|
SaveProperty | Custom | |
SetProperty | SaveProperty | |
SetSysVar | Custom | |
MessageTimer | Timer | |
SetLockScreen | Custom | Saves and sets form.lockScreen , resetting it when the instance goes out of scope. |
ScopeTimer | Custom | Upon destroy() debugout the object's scope lifetime in seconds.. |