INPUT/de

(Difference between revisions)
Jump to: navigation, search
(Funktion)
(Remarks)
Line 17: Line 17:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Remarks</span> =
+
= <span class="f_Header">Anmerkungen</span> =
 
<div style="padding: 0px; margin: 0px 0px 0px 4px;">
 
<div style="padding: 0px; margin: 0px 0px 0px 4px;">
 
{| width="567" cellspacing="0" cellpadding="1" border="1" style="border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;"
 
{| width="567" cellspacing="0" cellpadding="1" border="1" style="border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;"
Line 25: Line 25:
  
 
| valign="top" width="86%" style="width: 470px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="86%" style="width: 470px; border: 1px solid rgb(0, 0, 0);" |  
An optional string constant printed before the prompt character.
+
Optionale String-Konstante, die vor dem Prompt-Zeichen geschrieben wird.
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 32: Line 32:
  
 
| valign="top" width="86%" style="width: 470px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="86%" style="width: 470px; border: 1px solid rgb(0, 0, 0);" |  
A variable to accept the input value or a string.
+
Variable zur Aufnahme des Input-Wertes oder Strings.
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 39: Line 39:
  
 
| valign="top" width="86%" style="width: 470px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="86%" style="width: 470px; border: 1px solid rgb(0, 0, 0);" |  
A channel number, which identifies an opened file. This can be a hard coded constant or a variable.
+
Kanalnummer, die eine geöffnete Datei identifiziert. Kann eine Konstante oder eine Variable sein.
  
 
|}
 
|}
Line 45: Line 45:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
The INPUT routine can be used when you have an RS-232 interface on your uP.
+
Die INPUT-Routine kann benutzt werden wenn man einen Mikrocontroller mit serieller Schnittstelle hat.  
  
The RS-232 interface can be connected to a serial communication port of your computer.
+
Die serielle Schnittstelle kann (über einen RS-232 - TTL Konverter) mit der seriellen Schnittstelle eines PCs verbunden werden.
  
This way you can use a terminal emulator and the keyboard as an input device.
+
Auf dieses Weise kann man die Tastatur des PCs mit einem Terminalemulator-Programm für Eingaben benutzen.
  
You can also use the built-in terminal emulator.
+
Man kann auch den in BASCOM integrierten Terminal-Emulator verwenden.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
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.
+
Bei Benutzung des AVR-DOS Datei-Systems kann man Variableninhalte aus einer geöffneten Datei lesen. Da die Variablenwerte im ASCII-Format gespeichert sind werden die Daten automatisch in das richtige Format umgewandelt.
 +
 
 +
Wenn INPUT in Zusammenhang mit Dateien benutzt wird dann ist PROMPT nicht unterstützt.
  
When you use INPUT with a file, the prompt is not supported.
 
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>

Revision as of 01:21, 26 March 2013

Contents

Funktion

Ermöglicht Eingaben von der Tastatur, einer Datei oder über SPI.

 

 

Syntax

INPUT [" prompt" ] , var[ , varn ]

INPUT #ch, var[ , varn ]

 

 

Anmerkungen

Prompt

Optionale String-Konstante, die vor dem Prompt-Zeichen geschrieben wird.

Var,varn

Variable zur Aufnahme des Input-Wertes oder Strings.

Ch

Kanalnummer, die eine geöffnete Datei identifiziert. Kann eine Konstante oder eine Variable sein.

 

Die INPUT-Routine kann benutzt werden wenn man einen Mikrocontroller mit serieller Schnittstelle hat.

Die serielle Schnittstelle kann (über einen RS-232 - TTL Konverter) mit der seriellen Schnittstelle eines PCs verbunden werden.

Auf dieses Weise kann man die Tastatur des PCs mit einem Terminalemulator-Programm für Eingaben benutzen.

Man kann auch den in BASCOM integrierten Terminal-Emulator verwenden.

 

Bei Benutzung des AVR-DOS Datei-Systems kann man Variableninhalte aus einer geöffneten Datei lesen. Da die Variablenwerte im ASCII-Format gespeichert sind werden die Daten automatisch in das richtige Format umgewandelt.

Wenn INPUT in Zusammenhang mit Dateien benutzt wird dann ist PROMPT nicht unterstützt.


 

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.

 

 

Xmega-SPI

When receiving data from the SPI interface, you need to activate the SS pin. Some chips might need an active low, others might need an active high. This will depends on the slave chip.

When you use the SS=AUTO option, the level of SS will be changed automatic. Thus SS is made low, then the data bytes are received, and finally , SS is made high again.

 

Receiving data works by sending a data byte and returning the data that is shifted out. The data that will be sent is a 0. You can alter this in the library, _inputspivar routine.

You can not sent constants using the INPUT with SPI. So INPUT #10, "SPI", var  is not supported.

INPUT used with SPI will not wait for a return either. It will wait for the number of bytes that fits into the variable. SeeCONFIG SPIx for an example.

 

Number of Bytes

The compiler will receive 1 byte for a variable which was dimensioned as a BYTE.

It will receive 2 bytes for a WORD/INTEGER, 4 bytes for a LONG/SINGLE and 8 bytes for a DOUBLE.

As with all routines in BASCOM, the least significant Byte will be received first.

 

If you specify an array, it will receive one element.

With an optional parameter you can provide how many bytes must be received. You must use a semicolon (;) to specify this parameter. This because the comma (,) is used to receive multiple variables.

 

Sample

Dim Tmparray(5) As Byte  , Spi_send_byte As Byte , W as Word

Input #12 , Spi_receive_byte ; 1                         ' READ 1 byte

Input #12 , Tmparray(1) ; 1 , Tmparray(2) ; B       ' read 1 byte and 'b' bytes starting at element 2

 

 

 

 

 

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

Languages   English Deutsch  
Personal tools
Namespaces
Variants
Actions
Navigation
In other languages
Language