Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/18/05 14:42
Read: times


 
#97569 - No , again an undocumented statement
Responding to: ???'s previous message
Thanks Andy for your help , but in Basic it doesn't need to use the Comma , it was my problem in 8 years ago when i started to code in C , where you had to use Comma's .

I have to start to leave using Bascom...

here is the full help page about the Input instruction in Bascom Help (doesn't differ much to the Manual):
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 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
INPUTHEX PRINT $TIMEOUT


Example

'--------------------------------------------------------------
' (c) 1997-2002 MCS Electronics
'--------------------------------------------------------------
' file: INPUT.BAS
' demo: INPUT, INPUTHEX
'--------------------------------------------------------------
'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
End

by reading this help i don't see that a $timeout is needed in the code, now that i'm reading it again and again , i am starting to understand that the Option which is mentioned in this "' you need to use the TIMEOUT option." sentence didn't refers to the Inmput statement , but to the $TIMEOUT !
is this my lack of english , or do you experts find it also ambiguous ?
and there is one more intresting thing , this '$timeout' only is used for the INPUT statemnet !
here is the Help page about the $timeout :
Action
Compiler directive to specify that the TIMEOUT option is used with serial input.


Syntax
$TIMEOUT

Remarks
$TIMEOUT will modify the serial input routine so that it enables you to use the TIMEOUT with the INPUT, INPUTBIN, INPUTHEX etc. statements.

See also
INPUT , GET


Example
$TIMEOUT
DIM Name as string * 10
REM Now we can use theTIMEOUT option
INPUT "Name " , name TIMEOUT = 100000 'enable time out
INPUT "Name ", name 'wait until <13> pressed.


judge by yourself .

Farshid J.H.

List of 3 messages in thread
TopicAuthorDate
any experience w. Input stat. in Bascom            01/01/70 00:00      
   Are y ou sure?            01/01/70 00:00      
      No , again an undocumented statement            01/01/70 00:00      

Back to Subject List