Contents of GETLESS.TXT in FOXPROW\GOODIES\FNDATIONID: Q108175 2.50 2.50a 2.50b WINDOWS kbreadme The information in this article applies to:
SUMMARYBelow is the complete FoxPro for Windows GETLESS.TXT file found in the FOXPROW\GOODIES\FNDATION subdirectory. NOTE: This file contains eight questions about the EX1.APP application and how it implements a foundation READ. The answers to these questions are in the GETANS.TXT file. Both the EX1.APP and GETANS.TXT files are located in the FOXPROW\GOODIES\FNDATION subdirectory.
MORE INFORMATION
This note explains our thinking on new MODAL and associated window
concepts. It also introduces some minor improvements in FoxPro which are
available starting with FoxPro 2.5.
Event Loop ProgrammingIn order to produce applications with event-driven interfaces like FoxPro's own interface, some sophisticated developers have resorted to event loop programming similar to that utilized inside FoxPro itself and in environments like the Macintosh and Windows. We feel that coding a real event loop in the FoxPro language has very limited practicality for three reasons. First, the speed of the resulting application will be sub-optimal. Second, such an application is always in hard execution and, therefore, a CPU hog and unfriendly in multiprogramming environments like DESQview, Windows, or the Mac MultiFinder. Finally, such event loop programming is VERY complex conceptually, probably too complex for all but the most skilled developers and certainly inaccessible to beginners. That event loop programming was ever needed is, in fact, evidence of inadequate documentation and an incomplete original design. That event loop programming ever worked at all is testimony to the ingenuity and skill of you developers. Improvements have been made in FoxPro 2.0 so that event loop programming should almost never be required.
Single READ Interactions (with Multiple Windows)With FoxPro 2.0 it is very easy to incorporate many windows into a single READ. FoxPro handles virtually all aspects of coordinating windows containing GETs with other windows--notably Browse and text editing windows- -more or less automatically. Our general recommendation is that a single READ should correspond to a single interactive session, dedicated to a particular objective, regardless of the number of windows involved. For example, a single READ might be used for customer file maintenance, entering invoices and associated detail lines, entering hours worked into a payroll application, etc. If desired, such single READ interactions can include access to desk accessories, Browse windows, etc. Moreover, it's possible to restrict access to other windows as desired by use of the MODAL clause in conjunction with the WITH clause. The overall application structure which is most obvious and easiest to implement is to use traditional hierarchical menus, buttons, or other controls to invoke a series of single READ interactions which accomplish the application's objectives. This approach is generally recommended and produces applications which may have many lovely, object oriented, multi- window, event driven features, but which are traditional in overall architecture.
Programming Single READ InteractionsThe basic idea is to encompass in a single READ all the windows that you intend to interact with at a particular READ level. READ MODAL simply means that the user is prevented from interacting with windows not included in READ's cooperating set of windows. You will not be able to close, zoom, minimize, or move windows not involved in a READ MODAL. Also, if BEEP is SET ON, it'll beep when you click on a forbidden window. by use of the READ's ACTIVATE and DEACTIVATE clauses. The basic change was
in DEACTIVATE.
Formerly, DEACTIVATE would attempt to prevent windows from coming forward if the DEACTIVATE expression returned .F. Also, bringing a window forward which was not one of the READ windows would terminate the READ. This behavior (a) didn't generally work, (b) created insurmountable bugs, and (c) made it very difficult to coordinate BROWSE and other windows with READ in a controlled manner. (Upon reflection, you'll note that forcing termination of a READ when a non-READ window was brought forward is what actually forced you to write your own event loops in the first place.) In addition, this odd behavior could not be emulated under Windows or on the Mac. Here's what READ does now:
Note that in this deceptively simple change, lies the key to easily
coordinating BROWSE and other windows within a READ. The 'Clients' part of
the sample 'Organize' application illustrates the use of these new
constructs.
We'll upload a project named INV (to Library 2) which utilizes the tutorial databases to demonstrate how two Browse windows can be coordinated with a READ. Please index DETAIL.DBF on INO and PARTS.DBF on PNO before trying to run it. By the way, none of the above is incompatible with your FoxPro 1.02 applications. If a READ contains no new 2.0 clauses and it's a single- window READ, it's terminated when another window is brought forward. Of course, the Screen Builder generates READ CYCLE by default, which triggers the new behavior.
Coordinating Multiple READsNow let's discuss how to coordinate multiple (possibly multi-window) READs in an application. It is actually possible to create applications which are as modeless and fluid as FoxPro's own interface. From the interface point of view, it is entirely possible to write completely event-driven applications, applications where you can switch from one interactive session to another simply by clicking on the desired window. However, the constraints of your application will almost certainly dictate some limitations. For example, you can't permit updates to your general ledger in the midst of printing your balance sheet, you can't permit checks to be printed in the midst of calculating your payroll, etc. Also even though we've tried to make it as simple as possible, completely event driven programming remains conceptually complex. You will want to approach this area with care, starting with modest objectives. For example, a good approach might be to start by permitting, say, customers to be added, zip codes to be looked up, etc. in the midst of posting orders just by pointing at the appropriate window and clicking. In other words, pick a few of your single-READ interactions and permit them to interoperate just like FoxPro's own interface does. See the examples provided for illustrations of how to accomplish this. Eventually, the sophisticated developers among you will doubtless develop templates to automate or semi-automate this process.
Improvements in FoxProa. A READ with no GETs may now have a VALID clause. Such a READ will be b. When a GET-less READ having a VALID clause is executing, menus now
c. GET-less READs are now terminated in two ways:
formerly, ANY keystroke or mouse click terminated a GET-less
READ.
d. When a window containing GETs which is involved in the current READ is e. GENSCRN now emits code which does NOT redefine windows if they already
f. GENSCRN has also been modified so, if a required DBF is already open
g. WONTOP(), WLAST(), WOUTPUT() and similar functions which are used to
h. A new function WREAD([<window>]) has been provided. This function
i. READKEY() now accepts an optional argument of 1 which causes it to
j. The maximum number of nested READs has been increased to 5.
EX1: Event-Driven Example #1The first example is called 'EX1'. It demonstrates coordination of four different READ interactions, each of which use the 'control3' control panel. You can switch from one to the other just by clicking on the application window. Applications are launched by use of the Application menu. Execution of the entire system can be terminated by use of the Exit option in the Application menu. This example has been designed so you can utilize any available desk accessories or windows in conjunction with the application windows: Help, Filer, Calculator, Calendar/Diary, ASCII Chart, Special Characters, and Puzzle, editor windows, the project window, etc. Before you attempt to write your own multi-READ event driven code, we recommend you carefully study EX1 and be certain you can answer the following questions about its operation: 1. What would happen if the menu handling routine always immediately 2. Why is it necessary to specify the 'IN EX1.MPR' clause in the menu
3. Where is the code that handles the situation where an application window
4. What's the largest number of READs which are ever active at any one time
5. What ensures that the control panel vanishes when the last remaining
6. If you bring, say, the Calculator up on top of an application window, is
7. When you're executing EX1.APP and neither an application window nor the
8. When you're running in an application window and you click in another,
If you can answer all the above questions, you're ready to proceed to
the next example. (We'll post the answers later.)
EX2: Event-Driven Example #2This example is rather similar to EX1, but replaces the single invoice editing screen with the 'INV' application that, besides editing the invoice file, includes a different control panel 'control2' and two (2) BROWSE windows coordinated as part of the READ. Study EX2 carefully and you'll see that the changes required to handle this rather more complex situation were rather simple. If you can answer the 8 questions above about EX1, you should have no difficulty with EX2. And by now, you should have a general idea how to proceed in your own applications. Additional reference words: FoxWin 2.50 2.50a 2.50b KBCategory: kbreadme KBSubcategory: FxprgMacrosub
|
|
Last Reviewed: May 1, 1996 © 1999 Microsoft Corporation. All rights reserved. Terms of Use. |