INPUT or LINE INPUT Erases Existing Line When Accepting Input (43025)



The information in this article applies to:

  • Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0

This article was previously published under Q43025

SUMMARY

When accepting input with the INPUT or LINE INPUT statement on top of existing text (or pixels) on the screen, the rest of the line will be blanked out when you enter the first character. This behavior is a consequence of the feature that lets you use standard mouse editing on the entire input line.

To avoid the erasure, you can accept input using the INKEY$ function (see example below).

This information applies to Microsoft QuickBASIC Version 1.00, Microsoft BASIC Interpreter Versions 2.00, 2.10, and 3.00, and Microsoft BASIC Compiler Version 1.00 for the Apple Macintosh.

Another alternative is to use the EDIT FIELD statement for input that is delimited by a box. For more information, query on the following words:

DIALOG and EDIT and FIELD and QuickBASIC

MORE INFORMATION

The following is a sample program that demonstrates the erasing behavior during INPUT:
   LOCATE 1,3 : PRINT "*************"
   LOCATE 1,1 : INPUT A$
				
The following is what you see when this program starts:
  ?_*************
				
The existing line is erased (by the line editor) when you type a character. For example, the following output results when you type the letter a:
  ?a
				
To avoid the erasure, you can accept input using the INKEY$ function, as shown in the following example:
CALL TEXTFONT 4  'This font has equally-spaced (monospaced)
                 'characters that line up correctly on the "*".
TEXTSIZE 9
PRINT "*****************"
LOCATE 1,1
a$ = ""
i$ = INKEY$
WHILE i$ <> CHR$(13)   ' RETURN key terminates input.
  'checks for valid input from keyboard
  IF i$ <> "" AND i$ <> CHR$(8) THEN  ' Ignore null and BACKSPACE.
    a$ = a$ + i$
    LOCATE 1,1 : PRINT a$
    i$ = INKEY$
  END IF
  i$ = INKEY$
WEND
PRINT
' Waits until you press a key for program to end
WHILE INKEY$ = "": WEND
END
				
The following is what you see when this program starts:
************
				
As you type characters, the asterisks stay on the screen, as in the following:
John Doe****
				

Modification Type:MinorLast Reviewed:1/8/2003
Keywords:KB43025