Sample Procedure to Insert Spaces when TAB Key is Pressed

Last reviewed: June 27, 1995
Article ID: Q128632
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b, 2.6, 2.6a

SUMMARY

Below is a procedure demonstrating how to, within a program, insert spaces when the TAB key is pressed.

MORE INFORMATION

In the SETUP Code of your Screen, OR WHEN clause of an @ ... EDIT, or before a MODIFY MEMO or MODIFY FILE, add the following line to allow access to the program:

   ON KEY LABEL TAB DO EMULTAB

Below is the contents of EMULTAB.PRG:

   DEFINE WINDOW NEWTAB FROM 1,1 TO 5,22   && Setup a Window
   MOVE WINDOW NEWTAB CENTER
   ACTIVATE WINDOW NEWTAB
   PUBLIC NUMTAB
   NUMTAB = 4                                && Give a default of 4 Spaces
   @1,2 SAY "How Many Spaces?"
   @2,2 GET NUMTAB
   READ

   RELEASE WINDOW NEWTAB
   SET PROCEDURE TO EMULTAB
   ON KEY LABEL TAB DO TABEVAL WITH NUMTAB IN EMULTAB
   KEYBOARD '{TAB}'

   PROCEDURE TABEVAL
   PARAMETERS TABSIZE

   FOR i=1 TO TABSIZE
      KEYBOARD '{SPACEBAR}'
   NEXT

   ON KEY LABEL TAB DO EMULTAB
   RETURN

CAUTION: The default TAB functionality will be gone until the following command is entered:

   ON KEY LABEL TAB

This is sample code. You may modify it to suit your requirements.


Additional reference words: FoxWin 2.50 2.50a 2.50b 2.60 2.60a
KBCategory: kbprg kbcode
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: June 27, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.