Top  Previous  Next


Allows input from the keyboard during program execution.




INPUT [" prompt" ] , var [ , varn ]   [ NOECHO  ]  [ TIMEOUT = xx]





An optional string constant printed before the prompt character.


A variable to accept the input value or a string.


Disables input echoed back to the Comport.


Optional delay time. When you specify the delay time, the routine will return when no input data is available after the specified time. No timer is used but a long is used to count down.


The INPUT routine can be used when you have a RS-232 interface on your uP.

See the manual for a design of a RS-232 interface.

The RS-232 interface can be connected to a serial communication port of your computer.

This way you can use a terminal emulator and the keyboard as an input device.

You can also use the built in terminal emulator. A backspace will remove the last entered character.



Difference with QB

In QB you can specify &H with INPUT so QB will recognize that a hexadecimal string is used.

BASCOM implements a new statement: INPUTHEX.



See also






'                 (c) 1995-2006 MCS Electronics


'  file: INPUT.BAS



'To use another baudrate and crystalfrequency use the

'metastatements $BAUD =  and $CRYSTAL =

$baud = 1200                                                 'try 1200 baud for example

$crystal = 12000000                                           '12 MHz



'   When you need that the program times out on waiting for a character

'   you need to use the TIMEOUT option.

'   When the charcter is not received within the specified time ERR will be set to 1

'   otherwise ERR will be 0.

'   IMPORTANT : the TIMEOUT variable will use 4 bytes of internal memory



Dim V As Byte , B1 As Byte

Dim C As Integer , D As Byte

Dim S As String * 15                                         'only for uP with XRAM support


Input "Use this to ask a question " , V

Input B1                                                     'leave out for no question


Input "Enter integer " , C

Print C



Inputhex "Enter hex number (4 bytes) " , C

Print C

Inputhex "Enter hex byte (2 bytes) " , D

Print D


Input "More variables " , C , D

Print C ; " " ; D


Input C Noecho                                               'supress echo


Input "Enter your name " , S

Print "Hello " ; S


Input S Noecho                                               'without echo

Print S


'unremark next line and remark all lines above for the TIMEOUT option

'this because when you use TIMEOUT once, you need to use it for all INPUT statements

'Input "Name " , S Timeout = 0

'Print Err ; " " ; s