Generic Procedure to Increment Number or Date GET Fields

Last reviewed: April 17, 1995
Article ID: Q96350
The information in this article applies to:
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, and 2.5a

SUMMARY

In FoxPro, a generic procedure can be used to increment any numeric or date GET during a program. This procedure can also be used to emulate the spinner (spin box) control used in Windows-based applications.

MORE INFORMATION

The following example shows how a procedure defined in an ON KEY LABEL routine for the PLUS SIGN (+) key can increment a number or date by 1:

   ON KEY LABEL + DO increment WITH VARREAD()
   * pass the variable or field of the current GET
   SET TALK OFF
   CLEAR
   @ 5,5 GET num1 SIZE 1,5 DEFAULT 100
   @ 6,5 GET num2 SIZE 1,8 DEFAULT {01/01/93}
   @ 8,5 GET choice PICTURE "@*hn OK" SIZE 1,4 ;
      DEFAULT "OK" VALID    done()
   READ CYCLE
   ON KEY LABEL +

   FUNCTION done
   CLEAR READ
   RETURN .t.

   PROCEDURE increment
   PARAMETER field
   num = EVALUATE(field)
   * store the contents of the current GET to num
   num = num + 1          && increment the number or date
   STORE num TO &field
   * store the new number back to the current GET variable or field
   SHOW GETS
   RETURN

This procedure is generic and would apply to any GET that is in effect. The VARREAD() function will be able to determine the current GET and increment only that number.

If a spinner type of control is desired, this procedure can be used as a VALID clause on invisible or push buttons to simulate the operation of a spinner control.


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


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 17, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.