Action
Allows input from the keyboard or file during program execution.
Syntax
INPUT [" prompt" ] , var[ , varn ]
INPUT #ch, var[ , varn ]
Remarks
Prompt |
An optional string constant printed before the prompt character. |
Var,varn |
A variable to accept the input value or a string. |
Ch |
A channel number, which identifies an opened file. This can be a hard coded constant or a variable. |
The INPUT routine can be used when you have an RS-232 interface on your uP.
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.
For usage with the AVR-DOS file system, you can read variables from an opened file. Since these variables are stored in ASCII format, the data is converted to the proper format automatically.
When you use INPUT with a file, the prompt is not supported.
Difference with VB
In VB you can specify &H with INPUT so VB will recognize that a hexadecimal string is being used.
BASCOM implements a new statement : INPUTHEX.
See also
INPUTHEX , PRINT , ECHO , WRITE , INPUTBIN
Example
'-----------------------------------------------------------------------------------------
'name : input.bas
'copyright : (c) 1995-2005, MCS Electronics
'purpose : demo: INPUT, INPUTHEX
'micro : Mega48
'suited for demo : yes
'commercial addon needed : no
'-----------------------------------------------------------------------------------------
$regfile = "m48def.dat" ' specify the used micro
$crystal = 4000000 ' used crystal frequency
$baud = 19200 ' use baud rate
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
Dim V As Byte , B1 As Byte
Dim C As Integer , D As Byte
Dim S As String * 15
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
End