Buffering in the TASTRADE Sample ApplicationID: Q130656 3.00 WINDOWS kbtool The information in this article applies to:
SUMMARYThe ORDENTRY.SCX form in the C:\VFP\SAMPLES\MAINSAMP\FORMS directory contains controls as well as a grid to create a one-to-many form from tables in the TASTRADE.DBC database. This form uses optimistic buffering, as well as custom routines when records are appended, saved, or the record pointer is moved. Much of the code is supplied in the base class for the form, so it is not readily apparent when you modify the ORDENTRY.SCX form itself.
MORE INFORMATIONThe BufferMode property in the Ordentry.scx form itself sets optimistic buffering. This property causes grids to use optimistic table buffering and all other controls to use optimistic row buffering. The remaining code is located in the class used to create this form. The ParentClass property is set to tsbaseform. The ClassLibrary property is set to C:\VFP\SAMPLES\MAINSAMP\LIBS\TSBASE.VCX. These two pieces of information tell you what you need to know to look at the code behind the order entry form. 1. Choose Open from the File menu, and select Files of Type: Visual Class 2. Select the TSBASE.VCX file from the C:\VFP\SAMPLES\MAINSAMP\LIBS
Methods Used with the BufferMode PropertyThe following methods are used in conjunction with the BufferMode property to handle updates of data in the tables:
*Last
*Next
*Prior
NOTE: All methods names preceded with an asterisk (*) are user-defined
methods that were added to the form. The asterisk is to categorize the
methods here. The names are not preceeded with an * in the class library.
In most cases, this code could have been placed in a different method, such as the Click event of a button. The advantage of using special names for these methods is that the code is not overwritten in memory if the developer adds custom code to the default methods included in a form. The code to save or discard changes is encapsulated in two methods. The Restore method is the only method that reverts data through a TABLEREVERT() function. The Save method is the only method that saves data from the form into the table; it accomplishes this through a TABLEUPDATE() function. Each method sets the lAllRows parameter to true (.T.) for the TABLEREVERT() or TABLEUPDATE() function. This causes all updates to be written to disk or discarded and allows the method to work with row or table buffering. These two methods are called whenever it is necessary to discard changes to a record or save changes to a table. Both methods assume that the desired work area has been selected prior to invoking the method. The Restore method is called by the AddNew, AskToSave, Delete, First, Last, Next, and Prior methods. The Save method is called only by the AskToSave method. Additional reference words: 3.00 VFoxWin KBCategory: kbtool KBSubcategory: FxtoolFormdes
|
Last Reviewed: November 22, 1995 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |