Mouse Click Terminates READ VALID Statement

Last reviewed: April 29, 1996
Article ID: Q88674
The information in this article applies to:
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, and 2.5a
  • Microsoft FoxPro for Windows, versions 2.5 and 2.5a

SUMMARY

In a program, a READ is terminated when the user selects a field that is disabled by the VALID clause of the READ.

MORE INFORMATION

The program listed below defines three objects: AVAR1, AVAR2, and AVAR3. AVAR1 is a GET field with a VALID clause; AVAR2 and AVAR3 are buttons. When the program is run, AVAR2 is disabled and AVAR3 is enabled.

When the user enters data in AVAR1 and presses the ENTER key, AVAR2 is enabled and AVAR3 is disabled. The indicator then moves to AVAR2. However, if the user enters data in AVAR1 and then selects AVAR3, the READ is terminated and the program ends.

This situation occurs because the program disables AVAR3 when AVAR1 has a value. Selecting the object using the mouse has the same effect as pressing the ENTER key on the keyboard. If you select AVAR3 using the mouse, FoxPro does not have a logical position in which to place the indicator; therefore, it terminates the program.

To avoid terminating the program, use a WHEN clause, not a VALID clause, in the READ statement. If you enter data in AVAR1 and select AVAR3, FoxPro returns the indicator to AVAR1 because the mouse selection is invalid.

The following sample program demonstrates this situation:

   STORE SPACE(10) TO AVAR1
   @5,5 GET AVAR1 VALID MYFUNC()
   @7,5 GET AVAR2 PICT '@*C BUTTON 1' DEFA 0 DISABLE
   @9,5 GET AVAR3 PICT '@*C BUTTON 2' DEFA 1 ENABLE
   READ CYCLE

   FUNCTION MYFUNC
      IF EMPTY (AVAR1)
         SHOW GET AVAR2 DISABLE
         SHOW GET AVAR3 ENABLE
      ELSE
         SHOW GET AVAR2 ENABLE
         SHOW GET AVAR3 DISABLE
      ENDIF
   RETURN


Additional reference words: FoxWin FoxDos 2.00 2.50 2.50a
KBCategory: kbprg
KBSubcategory: FxprgGeneral


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 29, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.