PRB: Order of Read Level Clauses Different in Visual FoxProID: Q133739 The information in this article applies to:
SYMPTOMSThe order in which Visual FoxPro executes READ clauses is different from that of previous versions of FoxPro. For example, the READ DEACTIVATE clause in Visual FoxPro, in some cases, behaves differently in Visual FoxPro.
CAUSEVisual FoxPro now supports object oriented programming (OOP). This new event model has changed the order in which FoxPro processes certain events.
STATUSThis behavior is by design.
MORE INFORMATIONWhen developing applications in Visual FoxPro it is very important to learn the order of events. Because the event model in Visual FoxPro is greatly enhanced over previous versions, items may not fire when expected if compared to earlier versions of FoxPro.
Code SampleThe following example demonstrates how Visual FoxPro's READ DEACTIVATE clause fires in two different places depending on which version of FoxPro runs the program. Create the following program, and name it Readordr.prg:
When you run the Readordr.prg program, each of the events that fires is
written to a log file name Readordr.log. You can use this file to check the
order of events in Visual FoxPro or in a previous version of FoxPro.
Steps to Demonstrate BehaviorTo illustrate this point, execute the Readordr.prg program in Visual FoxPro, and then follow these steps: 1. When the screen is run, these events occur in this order:
2. From the first GET field (X1), press the TAB key to move the focus to
3. From the second GET field (Y1), press the TAB key again, this moves the
4. To exit the Readordr.prg program, press the F5 key and then the ESC key.
5. Run the same code in a previous version of FoxPro, and compare the log
Why Visual FoxPro Uses a Different Firing OrderThe reason why Visual FoxPro differs is because of the current event model. The Visual FoxPro order of events is described in the Visual FoxPro Help file in the "Visual FoxPro Event Sequence" topic. In the example, you press TAB to move from window1 to window2. The events are firing in the correct order. First, the VALID clause of Y1 determines if you may leave the object. Second, the WHEN clause is executed for the first object (X2) on window2. This occurs because Visual FoxPro's order of events executes the WHEN clause for the next object in the TAB order, before the form object (window1) loses the focus. Visual FoxPro has to first determine if the next object will get the focus before the current object loses the focus. When the form object (window1) loses the focus, the READ DEACTIVATE is executed. If for example, the WHEN clause for X2 fails, the form object (window1) will not lose focus, so the DEACTIVATE clause should not fire. Additional reference words: 3.00 VFoxWin KBCategory: kbprg kbcode kbprb KBSubcategory: FxprgRead |
Last Reviewed: August 2, 1995 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |