| prompt$ (optional) - text printed in front of the entry area; "" (default) |
|
Prints a prompt and reads back a line of text typed by the player. Input gives you a complete little text editor for the price of one command. It prints the prompt at the current text cursor, shows a blinking block cursor after it, and lets the player type until they press Enter - at which point the finished string is returned and the cursor drops to the start of the next line, exactly as Print would leave it. The editing keys are all handled for you: Backspace and Delete remove characters, Left and Right move within the line, Home and End jump to its ends, and Escape wipes the line so the player can start again. Holding a key repeats it. Only characters the current font can actually draw are accepted, so odd keys are quietly ignored. It draws with the current Color and the font set by SetFont, and like the whole Print family it works on the front buffer whatever SetBuffer is set to - so the text appears straight away without a Flip. Use Locate beforehand to choose where the prompt goes. The gotcha is that it blocks. Your game loop stops dead while the player types, so nothing animates and no timers advance. That makes Input perfect for a start-up options screen, a debug console or a quick tool, and a poor fit for a chat box in a live game - build that from GetKey instead. If the player closes the window while typing, Input returns an empty string. The result is always a string, so wrap it in Int or Float when you are asking for a number. See also: Print, Locate, GetKey, WaitKey, SetFont, Text. |
; Input Example
; -------------
; Input halts the program and reads a line of text typed by the
; user, returning it as a string
name$=Input$("What is your name? ")
Print "Hello there, "+name$+"!"
Print "Input returned a "+Len(name$)+" character string."
Print ""
Print "Press any key to close the example"
WaitKey
End