INPUT Statement ---------------------------------------------------------------------------- Action Allows input from the keyboard during program execution. Syntax INPUT ; " promptstring"{;|,} variablelist Remarks The following list describes the parts of the INPUT statement. ----------------------------------------------------------------------------- Part Description ---------------------------------------------------------------------------- ; Determines screen location of the Part Description ---------------------------------------------------------------------------- ; Determines screen location of the text cursor after the program user enters the last character of input. A semicolon immediately after INPUT keeps the cursor at the next character position. Otherwise, the cursor skips to the next line. promptstring A literal string that will be displayed on the screen before the program user enters data items into the data input field. ; Prints a question mark at the end of promptstring. , Prints promptstring without a question mark. Part Description ---------------------------------------------------------------------------- variablelist An ordered list of variables that will hold the data items as they are entered. The INPUT statement causes a running program to pause and wait for the user to enter data from the keyboard. The number and type of data items required from the user is determined by the structure of variablelist. The variables in variablelist can be made up of one or more variable names, each separated from the next by a comma. Each name may refer to. - A simple numeric variable. - A simple string variable. - A numeric or string array element. - A record element. The number of entered data items must be the same as the number of variables in the list. The type of each entered data item must agree with the type of the variable. If either of these rules is violated, the program will display the prompt Redo from start and no assignment of input values will be made. The INPUT statement determines the number of entered data items in a list as follows. The first character encountered after a comma that is not a space, carriage return, or line feed is assumed to be the start of a new item. If this first character is a quotation mark ("), the item is typed as string data and will consist of all characters between the first quotation mark and the second. Not all strings have to start with a quotation mark, however. If the first character of the string is not a quotation mark, it terminates on a comma, carriage return, or line feed. Input stored in a record must be entered as single elements. For example. TYPE Demograph FullName AS STRING * 25 Age AS INTEGER END TYPE DIM Person AS Demograph INPUT "Enter name and age. "; Person.FullName, Person.Age You may want to instruct the user on how it is possible to edit a line of input before pressing the Enter key to submit the line to the program. The following list describes the key combinations that allow you to move the cursor, delete text, and insert text on the input line. ----------------------------------------------------------------------------- Keystrokes Edit function ---------------------------------------------------------------------------- Ctrl+M or Enter Store input line. Ctrl+H or Backspace Delete the character to the left of the cursor, unless the cursor is at the beginning of the input, in which case it deletes the character at the cursor. Ctrl+\ or Right Arrow Move cursor one character to the right. Ctrl+] or Left Arrow Move cursor one character to the left.. Ctrl+F or Ctrl+Right Arrow Move cursor one word to the right. Ctrl+B or Ctrl+Left Arrow Move cursor one word to the left. Ctrl+K or Home Move cursor to beginning of input Keystrokes Edit function ---------------------------------------------------------------------------- Ctrl+K or Home Move cursor to beginning of input line. Ctrl+N or End Move cursor to end of input line. Ctrl+R or Ins Toggle insert mode on and off. Ctrl+I or Tab Tab right and insert (insert mode on), or tab right and overwrite (insert mode off). Del Delete the character at the cursor. Ctrl+E or Ctrl+End Delete to the end of the line. Ctrl+U or Esc Delete entire line, regardless of cursor position. Ctrl+T Toggle function key label display Keystrokes Edit function ---------------------------------------------------------------------------- Ctrl+T Toggle function key label display on and off at bottom of screen. Ctrl+C or Ctrl+Break Terminate input (exit compiled program). When you use INPUT with ISAM programs, BASIC performs a CHECKPOINT operation every 20 seconds during an INPUT polling loop. A CHECKPOINT writes open database buffers to disk. If the user can be limited to using the Enter and Backspace keys for editing, you can reduce the size of the .EXE file by linking with the stub file NOEDIT.OBJ. If the user will be entering decimal integers only, you can save between 1.6K and 11K in the size of a non-stand-alone .EXE file by linking with the stub file NOFLTIN.OBJ. This places the following restrictions on user input. - Decimal numbers only (no leading &H, &O, or & base specifiers). - No trailing type specifiers ( %, &, !, #, @, or $). - No decimal point, E, or D (for example 1.E2 cannot be used instead of the integer 100). See Also INKEY$ Example This example calculates the area of a circle from its radius. The program uses the INPUT statement to allow the user to supply values of the variable. CLS PI = 3.141593. R = -1 DO WHILE R PRINT "Enter radius (or 0 to quit)." INPUT ; "If radius = ", R IF R > 0 THEN A = PI * R ^ 2 PRINT ", the area of the circle ="; A END IF PRINT LOOP Output Enter radius (or 0 to quit). If radius = 3, the area of the circle = 28.27434 Enter radius (or 0 to quit). If radius = 4, the area of the circle = 50.26549 Enter radius (or 0 to quit). If radius = 0