INPUT

Action

Allows input from the keyboard during program execution.
Reads data from a file

 

 

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 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 automaticly.

When you use INPUT with a file, the prompt is not supported.

 

 

Difference with QB

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

BASCOM implements a new statement : INPUTHEX.

 

 

 Example

'--------------------------------------------------------------
' (c) 1999-2000 MCS Electronics
'--------------------------------------------------------------
' file: INPUT.BAS
' demo: INPUT, INPUTHEX
'--------------------------------------------------------------
'To use another baudrate and crystalfrequency use the
'metastatements $BAUD = and $CRYSTAL =
$baud = 9600 'try 1200 baud for example
$crystal = 4000000 '12 MHz

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

Dim X As Byte
Echo On
Inputhex "Enter a number " , X 'ask for input
Echo Off
Inputhex "Enter a number " , X 'ask for input
Echo On
End