Sample Procedure to Insert Spaces when TAB Key is Pressed

ID: Q128632

The information in this article applies to:

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

Last Reviewed: June 27, 1995