Foundation Changes
visual foxpro
foxpro
visual foxpro
  visual foxpro
foxpro
visual foxpro
Contact Us
...the professional framework for FoxPro

  Home | News | Products | Services | Support | Newsgroups | Training | Downloads | Purchase

 
  Information
 
 
  Free Trials
 
Visual ProMatrix
Sample Apps
VisualRep
   
  ProMatrix Store
 
 

VPM Enterprise Foundation Changes


Changes have been made to the basic foundation of VPM applications. The benefit of these changes is that they make VPM applications more OOP-like and also better able to handle errors that cause VFP to clear memory.

1.   Object References: Object references are no longer stored in public memvars. When certain errors occur, VFP clears the memory, including memvars used to hold object references. This basically trashes the VPM environment, resulting in an endless number of errors being generated, many times causing the user to have to Ctrl+Alt+Del and end the task. Since VFP doesn’t release the _SCREEN variable when it clears the memory, we will store the object reference of the application object in a property of _SCREEN that is created at runtime. The object references of the Messaging and Security objects will be stored in properties of the application object, just like the object references of the form toolbar (oToolbar) and application toolbar (oAppToolbar). The object reference of the International object will be stored in a property of the application object to be consistent with how the other object references are stored.

Object
Previous Object Reference
New Object Reference

Application

Memvar oApp

Property _SCREEN.oApp

International

Property _SCREEN.oInt

Property _SCREEN.oApp.oInt

Messaging

Memvar oMessage

Property _SCREEN.oApp.oMessage

Security

Memvar oSec

Property _SCREEN.oApp.oSec

 

2.   Data Handling Code: Data handling code has been moved from form class methods to application object methods. The same form methods are called as always, but their purpose now is to handle interface-specific tasks like displaying messages, dealing with form and control properties, and handling Related Forms functionality. The form methods now call methods of the application object to handle data-specific tasks like adding, deleting, saving, and restoring records. Application object methods also handle functions such as referential integrity, default values, audit trail, DD data retrieval, record pointer movement, setting filters, and setting relations.

 

3.   Main Program: Most of the main program (S<Prefix>FMAN) functionality has been moved into methods of the application object. Moving the main program functionality into multiple methods of the application object produces the benefit of allowing the user to easily modify individual parts of this functionality. The main program code is also simplified as follows.

SET TALK OFF

* Refox lines used when branding the application.

IF .F.

   _ReFox_=(9876543210)

   _ReFox_=(9876543210)

ENDIF

* Instantiate the Application object.

SET CLASSLIB TO ProApp ADDITIVE

SET CLASSLIB TO VPMApp ADDITIVE

_SCREEN.AddProperty('oApp')

_SCREEN.oApp = CREATEOBJECT('ProApp')

IF TYPE('_SCREEN.oApp') <> 'O'

   RELEASE CLASSLIB ProApp,VPMApp

   RETURN

ENDIF

* Initialize the application environment, bring up the application interface, and issue

* the READ EVENTS command. Pass the application prefix to the Startup method to identify

* the application being run.

_SCREEN.oApp.Startup('VSA')

* The CLEAR EVENTS command has been issued so release the Application object and exit

* the application.

_SCREEN.oApp.Cleanup_ExitApplication()

_SCREEN.oApp = .F.

**********************

FUNCTION AppEntryError

**********************

* The application's initial ON ERROR command calls this function when an error occurs

* before complete entry into the application has been attained. Therefore, the normal

* method if displaying error messages using the messaging system cannot be used.

LPARAM stnErrNum,stcMess,stcCode,stcProg16,stnCurLine

slnCodeLength = 191-LEN(ALLTRIM(STR(stnErrNum)))-LEN(stcMess)-LEN(stcProg16)-;

   LEN(ALLTRIM(STR(stnCurLine)))

IF slnCodeLength > 0

   WAIT WINDOW 'ERROR #: '+ALLTRIM(STR(stnErrNum))+CHR(13)+'MESSAGE: '+stcMess+CHR(13)+;

      'PROGRAM: '+stcProg16+CHR(13)+'LINE #: '+ALLTRIM(STR(stnCurLine))+CHR(13)+;

      'CODE: '+LEFT(stcCode,slnCodeLength)+CHR(13)+CHR(13)+'Press any key...'

ELSE

   WAIT WINDOW 'ERROR #: '+ALLTRIM(STR(stnErrNum))+CHR(13)+'MESSAGE: '+stcMess+CHR(13)+;

      'PROGRAM: '+stcProg16+CHR(13)+'LINE #: '+ALLTRIM(STR(stnCurLine))+ CHR(13)+;

      CHR(13)+'Press any key...'

ENDIF

_SCREEN.oApp.Cleanup_ExitApplication()

_SCREEN.oApp = .F.

QUIT

 

The main program now runs the Startup method of the application object, which in turn runs the following methods. If any of these methods return a value of false (.F.) or generates an error, the application is immediately exited.

Method
Description

InitializeProperties()

Initialize selected properties.

SaveEnvironment()

Save certain environment settings so that they can be restored when the application is exited.

IssueOnError()

Invoke the initial error handler. If an error occurs prior to the user gaining access to the application, the error handler will make sure the application is exited.

SetClassLib()

Open the visual class libraries containing class definitions.

InstantiateBusinessRulesObject()

Instantiate the Business Rules object. The object reference is stored in a property of the application object, oBusinessRules.

ReleaseToolbars()

Hide all VFP toolbars.

CloseProjectManager()

Make sure that the Project Manager is closed.

RegisterDLLFunctions()

Register the Dynamic-Link Library (DLL) functions used in the application.

ModifyMainVFPWindow()

Modify the main Visual FoxPro window.

SetInitialEnvironment()

Set the initial application environment.

InstantiateInternationalObject()

Instantiate the International object. The object reference is stored in a property of the application object, oInt.

InstantiateMessagingObject()

Instantiate the Messaging object. The object reference is stored in a property of the application object, oMessage.

IssueOnShutdown()

Issue the ON SHUTDOWN command.

LoadDriveSwappingArray()

Perform the initial loading of the Drive Swapping array.

SetEnvironment()

Set additional environment settings for the application.

InstantiateSessionObject()

Instantiate a Session object to create a private data session where tables and views can be opened. The object reference is stored in a property of the application object, oSession.

OpenAtStartup_PDS()

Open the data dictionary and security view cursors that will remain open while the application is running. Leaving the cursors open will reduce network traffic and connection use. The cursors are opened in the private data session created for the Session object.

OpenAtStartup_DDS()

Open the tables and view cursors that are identified as “Open At Startup” in the data dictionary. The tables and views are opened in the default data session.

LoadAdminToolsArray()

Load the Admin Tools array and set Help on or off.

DefineFunctionKeys()

Define the function keys.

DisplayLogo()

Display the logo and copyright notice.

InstantiateSecurityObject()

Instantiate the Security object. The object reference is stored in a property of the application object, oSec.

RunLoginForm()

Run the Login form.

LoadDriveSwappingArray()

Perform the secondary loading of the Drive Swapping array.

RunIntroductoryForm()

Run the Introductory form.

OpenDBC()

Open the database identified in the cDatabase property.

RemoveLogo()

Release the logo if the lReleaseLogo property is set to .T..

RunMainMenu()

Run the main menu.

InstantiateApplicationToolbar()

Instantiate the application toolbar.

PerformStartupAction()

Perform startup action (run program, form, etc.).

IssueOnError()

Invoke the permanent error handler.

 

When the application is exited, the ExitApplication method of the application object is now run, which in turn causes the following methods to be run.

Method
Description

Cleanup()

Perform the application cleanup activities. This method runs the next two methods listed below and then issues the CLEAR EVENTS command. At that point control returns to the main program, which runs the Cleanup_ExitApplication method of the application object, which then runs the remaining methods listed below.

ReleaseSystemWindows()

Release any VFP system windows that might be active.

ReleaseApplicationForms()

Release any application forms that might be active.

ReleaseApplicationForms()

Release any application forms that might be active. This would include any forms that were brought up during application startup but had an error occur, causing the application to be exited. In this case, the Cleanup method is not run and the call to ReleaseApplicationForms() in that method is not run.

ReleaseApplicationToolbar()

Release the application toolbar.

ReleaseSecurityObject()

Release the Security object.

RemoveLogo()

Remove the logo and copyright notice objects from the main VFP window.

ClearDLLFunctions()

Clear the Dynamic-Link Library (DLL) functions used in the application.

ReleaseBusinessRulesObject()

Release the Business Rules object.

ReleaseClassLib()

Close the class libraries opened by the application.

ShowToolbars()

Show all toolbars that were hidden in the ReleaseToolbars method.

ReleaseMessagingObject()

Release the Messaging object.

ReleaseInternationalObject()

Release the International object.

ReleaseSessionObject()

Release the Session object.

RestoreEnvironment()

Restore certain environment settings that were in effect when the application was run.

 

4.   Global Memory Variables: Global memvars were used to store the names of tables, forms, and programs to be run in the application. These memvars will no longer be used. Instead, properties of the application object will be used. Also, programs that were called through the use of these global memvars have been deleted and the program code moved into application object methods.

Global Memvar

Description

New Property or Method

sgaDrvSwap

Drive swapping array

aDrvSwap

sgaTools

Admin Tools array

aTools

sgcActDBF

Activity table name

cActDBF

sgcAppPre

Application prefix

cAppPre

sgcAppTitle

Application title

cAppTitle

sgcAudDBF

Audit Trail table name

cAudDBF

sgcCRI

Referential Integrity program name (deleted)

ReferentialIntegrity()

sgcCurPre

Application prefix

cCurPre

sgcCWhn

When program name (deleted)

ControlWhen()

sgcEEH

Error Handling program name (deleted)

AdminTool_ErrorHandling()

sgcErrDBF

Error table name

cErrDBF

sgcFCT

Admin Tool program name (deleted)

RunAdminTool()

sgcFCTA

Load Admin Tools array program name (deleted)

LoadAdminToolsArray()

sgcFDS2

Load Drive Swapping array program name (deleted)

LoadDriveSwappingArray()

sgcFDS3

Swap Drive program name (deleted)

SwapDrive()

sgcFEnv

Set environment program name (deleted)

SetEnvironment()

sgcFormIcon

Form icon name

cFormIcon

sgcHelpDBF

Help file name

cHelpFile

sgcHF1

F1 help program name (deleted)

AdminTool_F1()

sgcHF2

F2 help program name (deleted)

AdminTool_F2()

sgcHF2R

“Referential” Picklist form name

cFieldPicklistForm_Referential

sgcHF2S

“Set” Picklist form name

cFieldPicklistForm_Set

sgcHF3

F3 help program name (deleted)

AdminTool_F3()

sgcHF3F

F3 help form name

cFieldDescriptionForm

sgcHomeDir

Home directory

cHomeDir

sgcPath

VFP path string

cPath

sgcPDD0

Database data dictionary table name

cPDD0

sgcPDD1

Table data dictionary table name

cPDD1

sgcPDD2

Field data dictionary table name

cPDD2

sgcPDF3

F3 help data dictionary table name

cPDF3

sgcPDInd

Index Tag Information data dictionary table name

cPDInd

sgcPjDBF

Application’s Data directory

cPjDBF

sgcPjHome

Application’s Home directory

cPjHome

sgcPjRpt

Application’s Reports directory

cPjRpt

sgcSetList

Used by the SetPush and SetPop methods to store the current status of the SET commands.

cSetList

sgcSInt

Introductory form name

cIntroductoryForm

sgcSMCF

Menu, Control, and Field Security program name (deleted)

AdminTool_MCFSecurity()

sgcSSA

Login form name

cLoginForm

sgcTempPath

Windows temporary file directory

cTempPath

sgcUAct

Activity Tracking program name (deleted)

AdminTool_ActivityTracking()

sgcUAl

Alert message program name (deleted - use messaging system instead)

 

sgcUCpy

Copy/Move table form name

cCopyMoveTableForm

sgcUDir

Folder existence check program name (deleted)

FolderExists()

sgcULgo

Logo program name

cLogoProgram

sgcUMv

Run Mover Form program name (deleted)

RunMoverForm()

sgcUND

Create Folder program name (deleted)

CreateFolder()

sgcUPop

Pop SET command program name (deleted)

SetPop()

sgcUPsh

Push SET command program name (deleted)

SetPush()

sgcURL

Lock Record program name (deleted)

LockRecord()

sgcURP

Reindex/Pack Tables form name

cReindexPackTablesForm

sgcUserDBF

User table name

cUserDBF

sgcUSP

Shorten Path program name (deleted)

ShortenPath()

sgcUUse

Open Table program name (deleted)

OpenTable()

sgcVFld

Field Validation program name (deleted)

AdminTool_FieldValidation()

sglLogo

Determines if logo is displayed

lLogo

sglQuitConf

Determines if exit application confirmation message is displayed

lQuitConf

 

New properties of the application object have been created to allow for the specification of the forms and programs to be run in the application that were previously hard-coded and not run through the use of global memvars.

Description

New Property

Condition Builder form name

cConditionBuilderForm

Control Permissions form name

cControlPermissionsForm

Copy Permissions form name