Action
Allows input from
the keyboard during program execution.
Syntax
INPUT [" prompt"
] , var [ , varn ] [ NOECHO ] [ TIMEOUT = xx]
Remarks
prompt An optional
string constant printed before the prompt character.
Var,varn A variable to accept the input value or a string.
NOECHO Disables input echoed back to the Comport.
TIMEOUT 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 build 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
INPUTHEX PRINT $TIMEOUT
Example
'--------------------------------------------------------------
' (c) 1997,1998 MCS Electronics
'--------------------------------------------------------------
' file: INPUT.BAS
' demo: INPUT, INPUTHEX
'--------------------------------------------------------------
'To use another baud rate and crystal frequency use the
'metastatements
$BAUD = and $CRYSTAL =
$baud = 1200
'try 1200 baud for example
$crystal = 12000000
'12 MHz
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 'suppress echo
Input
"Enter your name " , S
Print "Hello " ; S
Input
S Noecho 'without echo
Print S
End
|