The information in this article applies to:
- Microsoft FoxPro for Windows, versions 2.5x, 2.6
- Microsoft FoxPro for MS-DOS, versions 2.5x, 2.6
- Microsoft FoxPro for Macintosh, versions 2.5b, 2.5c
SUMMARY
This article explains how to create a screen (.SCX) object that will accept
character input, SEEK, and refresh screen objects and Browse windows on a
character-for-character basis as each character is entered in the object.
The basic process used in this article is to trap for keyboard input while
simulating input into a GET field.
MORE INFORMATION
- Open the TUTORIAL\CUSTOMER database supplied with FoxPro.
2. Make certain there is an index tag called COMPANY based on the
COMPANY field. The code that performs the sequential search is case
sensitive. If you want the search process to ignore case, base the
index on the COMPANY field on the UPPER value of the field, then also
SEEK the UPPER value of mComp.
- Create a new screen.
- Place the following code in the Setup code snippet:
DEFINE WINDOW x FROM 20,0 TO 30,50 FLOAT GROW
BROWSE WINDOW x NOWAIT
mComp = '' && null
SET ORDER TO company
This will create a Browse window in addition to the main GET screen
that is used to visually display the searched records.
- In FoxPro for Windows and Macintosh, use the Field tool to place an
input field on the screen with COMPANY as its input expression. (In
FoxPro for MS-DOS, choose Field from the Screen menu.) Mark the field
as initially disabled. This field will demonstrate the screen
expressions being updated as you enter the search expression.
- In FoxPro for Windows and Macintosh, use the Field tool again to place
another input field on the screen with the variable mComp as its input
expression. (In FoxPro for MS-DOS, choose Field from the Screen menu.)
- In the WHEN clause of mComp, place the following code:
mComp = ''
SHOW GET mComp
DO WHILE .T.
mlast = INKEY(0)
DO CASE
CASE mlast = 13 && RETURN Key pressed
_CUROBJ= OBJNUM(mdone) && or any object you want next
SHOW GET mdone
EXIT
CASE mlast = 127 && BACKSPACE Key pressed
mcomp = SUBSTR(mcomp,1,LEN(mcomp)-1)
SET NEAR ON
SEEK mcomp
SET NEAR OFF
SHOW WINDOW customer REFRESH
SHOW GETS
CASE mlast >= 48 AND mlast <= 57 OR;
mlast >= 65 AND mlast <= 90 OR;
mlast >= 97 AND mlast <= 122 OR;
mlast = 32 && 0-9, A-Z, a-z, or Spacebar
mcomp = mcomp+CHR(mlast)
SET NEAR ON
SEEK mcomp
SET NEAR OFF
SHOW WINDOW customer REFRESH
SHOW GETS
OTHERWISE && Do nothing, no character to process
ENDCASE
ENDDO
- Place a Quit push button on the screen.
- From the Program menu, choose Generate.
- In FoxPro for Windows or Macintosh, choose the More button to display
additional generation options. One of those options is a push button
labeled "Associated Windows". In FoxPro for MS-DOS, this option appears
as a check box in the dialog box that opens right after you choose
Generate.
- Select the Associated Windows option. Type "customer" (without the
quotation marks) as the name of the associated window.
- Finish generating the screen and run it.
To begin entering the name of a company to search for, click the MCOMP
field. To leave the input process, you must press the ENTER key.
|