Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 03:44 27 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : "Input" command cause trouble

Author Message
Hansaplast
Newbie

Joined: 13/07/2023
Location: Hong Kong
Posts: 10
Posted: 03:39am 15 Dec 2023
Copy link to clipboard 
Print this post

Is there is any mistake by me (PICOMITE)?

Try this:

PRINT "Input Power ON Time (HHMMSS): "
INPUT a$
PowerOn = VAL(a$) : PAUSE 50
PRINT PowerOn

PRINT "Input Power OFF Time (HHMMSS): "
INPUT b$
PowerOff = VAL(b$) : pause 50
PRINT PowerOff

...and you will see that after the 1st. "Input" command input the software
will jump over the 2nd. "Input" command line without any input.

> RUN
Input Power ON Time (HHMMSS):
? 150000
150000
Input Power OFF Time (HHMMSS):
?  0

What I did wrong????
Edited 2023-12-15 13:55 by Hansaplast
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 04:04am 15 Dec 2023
Copy link to clipboard 
Print this post

Works for me. Others have mentioned that sometimes there is a need to clear the keyboard buffer of stray characters. Search for that.
WEB A:/> list
Print "Input Power ON Time (HHMMSS): "
Input a$
PowerOn = Val(a$) : Pause 50
Print PowerOn

Print "Input Power Off Time (HHMMSS): "
Input b$
PowerOff = Val(b$) : Pause 50
Print PowerOff

Sub mm.prompt
 Print "WEB "Cwd$"> ";
End Sub
End
WEB A:/> run
Input Power ON Time (HHMMSS):
? 123456
123456
Input Power Off Time (HHMMSS):
? 234567
234567
WEB A:/>
 
Hansaplast
Newbie

Joined: 13/07/2023
Location: Hong Kong
Posts: 10
Posted: 04:21am 15 Dec 2023
Copy link to clipboard 
Print this post

Under Basic it should be

PRINT "Input Power ON Time (HHMMSS): "
LINE INPUT a$
PowerOn = VAL(a$)
PRINT PowerOn

PRINT "Input Power OFF Time (HHMMSS): "
LINE INPUT b$
PowerOff = VAL(b$)
PRINT PowerOff

Same program in QB64 work fine !

So for me it's a PicoMite BUG

Rem: Input is via USB
 
Hansaplast
Newbie

Joined: 13/07/2023
Location: Hong Kong
Posts: 10
Posted: 04:26am 15 Dec 2023
Copy link to clipboard 
Print this post

 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6098
Posted: 04:28am 15 Dec 2023
Copy link to clipboard 
Print this post

It sounds like you have the end of line in your terminal program set to CRLF

Try changing that to LF

The first end-of-line character gets used up for the first input then the second end-of-line character is seen by the second INPUT command, hence the empty result.

Not a bug.

Jim
VK7JH
MMedit   MMBasic Help
 
Hansaplast
Newbie

Joined: 13/07/2023
Location: Hong Kong
Posts: 10
Posted: 04:33am 15 Dec 2023
Copy link to clipboard 
Print this post

I use MM Edit as test platform and the MM Chat
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 04:51am 15 Dec 2023
Copy link to clipboard 
Print this post

Adding this before the second input may help if you don't want to change the terminal settings.
do : loop until inkey$ = ""
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6098
Posted: 04:57am 15 Dec 2023
Copy link to clipboard 
Print this post

I suggest you update MMEdit to the latest version.
Then you will be able to set the end-of-line characters
VK7JH
MMedit   MMBasic Help
 
Hansaplast
Newbie

Joined: 13/07/2023
Location: Hong Kong
Posts: 10
Posted: 04:59am 15 Dec 2023
Copy link to clipboard 
Print this post

Example from Geoff's PicoMite Manual, Page 22:

For example:
OPEN "numbers.txt" FOR INPUT AS #1
LINE INPUT #1, a$
LINE INPUT #1, b$
CLOSE #1
x = VAL(a$) : y = VAL(b$)
Following this the variable x would have the value 123 and y the value 56789.

Modified:
LINE INPUT a$
LINE INPUT b$
x = VAL(a$) : y = VAL(b$)
PRINT x,y

The result:

> RUN
123456
0 123456
>

It's a BUG !
 
Hansaplast
Newbie

Joined: 13/07/2023
Location: Hong Kong
Posts: 10
Posted: 05:00am 15 Dec 2023
Copy link to clipboard 
Print this post

in the Picomite Version MMBasic Ver 5.07.07
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 05:12am 15 Dec 2023
Copy link to clipboard 
Print this post

  Quote  It's a BUG !
As Jim said there is no bug. At the MMEdit end CRLF is being sent but only CR is needed. the LF character becomes the second input.

I have just tested your program again with the terminal line endings set to CRLF and it produces your symptoms.
Adding the line in my previous post fixes it, as does changing back to CR only.
Print "Input Power ON Time (HHMMSS): "
Input a$
PowerOn = Val(a$) : Pause 50
Print PowerOn
Do : Loop Until Inkey$ = ""
Print "Input Power Off Time (HHMMSS): "
Input b$
PowerOff = Val(b$) : Pause 50
Print PowerOff

Edited 2023-12-15 15:13 by phil99
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6098
Posted: 05:13am 15 Dec 2023
Copy link to clipboard 
Print this post

The BUG is in the old version of MMEdit that you are running.
Later versions let you easily change the end-of-line.
Then you can see the differences.
VK7JH
MMedit   MMBasic Help
 
amigawizard

Regular Member

Joined: 15/08/2023
Location: Australia
Posts: 43
Posted: 05:14am 15 Dec 2023
Copy link to clipboard 
Print this post

works  for  Me  2 !

LINE INPUT a$
LINE INPUT b$
x = VAL(a$) : y = VAL(b$)
PRINT x,y


      on the  command line

      using  minicom
       or telnet  on  Putty

             no  BUG !  here ..

             Wayne !

`
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024