How to Change Data in a GET Field from a VALID Procedure

Last reviewed: April 29, 1996
Article ID: Q101590
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, version 3.0
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5x, 2.6x
  • Microsoft FoxPro for Windows, versions 2.5x, 2.6x

When a GET field's VALID procedure returns FALSE, the original value contained by the field (the value before the user entered it) will be restored, and the user will get an error message indicating that the value entered was invalid. If the programmer wants to blank the field (fill it with spaces, for example) rather than restore the original value, the VALID procedure must return a value other than FALSE. The programmer must then use other methods for keeping the user in the field, such as setting _CUROBJ to the same GET object or returning 0 (zero).

The following program illustrates how to have the VALID procedure return TRUE and yet make sure the user still remains in the same GET field through use of the _CUROBJ system variable:

   CLEAR ALL
   CLEAR
   DEFINE WINDOW awind FROM 1,1 TO 10,30
   ACTIVATE WINDOW awind
   @1,7 GET m.what DEFAULT "      "
   @3,1 SAY "DATA: "
   @3,7 GET m.data DEFAULT "      " VALID dv()
   READ CYCLE
   RELEASE WINDOW awind

   FUNCTION dv
   IF ALLTRIM(m.data) !="EXIT"    && Only "valid" data in this example
                                  && is "EXIT" to exit the field.
      m.data="      "         && If data not valid, clear the data.
      SHOW GET m.data         && Refresh the GET.
      _CUROBJ=OBJNUM(m.data)  && Stay in the same GET.
      RETURN .T.              && Must return TRUE to clear the GET field.
   ENDIF


Additional reference words: VFoxWin 3.00 FoxDos FoxWin 2.00 2.50 2.50a
2.50b 2.60 2.60a
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.