Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 16:27 09 May 2025 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 : Problem with INPUT A$ and '',''

Author Message
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 935
Posted: 06:21pm 26 Mar 2025
Copy link to clipboard 
Print this post

My test environment: RP2040 GEEK with "PicoMiteRP2040V6.00.02RC7" and Tera Term

Hi to all!

If I enter “,” in the following test program, it is apparently simply ignored! Other characters are displayed with PRINT A$ - but a “,” is simply ignored? WHY???

Option Explicit

Dim A$ As String

Do
 Input A$
 Print A$
Loop


Frank
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10062
Posted: 06:51pm 26 Mar 2025
Copy link to clipboard 
Print this post

, is the input separator

manual page 116
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4851
Posted: 07:13pm 26 Mar 2025
Copy link to clipboard 
Print this post

Frank,

This is something that has been in Basic since 1964.... The comma separates input values, like in a CSV file.

Volhout
PicomiteVGA PETSCII ROBOTS
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 935
Posted: 07:31pm 26 Mar 2025
Copy link to clipboard 
Print this post

Okay, then I probably have to read in individual characters with INKEY$ until a RETURN occurs in order to be able to read in a “,”?

@Volhout:
To be honest - I had never paid attention to the “,” in INPUT$ before    - I had never needed it in a string...

Frank
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1526
Posted: 08:21pm 26 Mar 2025
Copy link to clipboard 
Print this post

  Frank N. Furter said  Okay, then I probably have to read in individual characters with INKEY$ until a RETURN ...

Hi Frank,
or Line Input?
Regards
Michael
causality ≠ correlation ≠ coincidence
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2137
Posted: 08:37pm 26 Mar 2025
Copy link to clipboard 
Print this post

tbh, INPUT is a bit of a hangover from the earliest days of Dartmouth BASIC. I never use except in very quick scribbles of code that I don't intend to take any further. INPUT is very limited in the control you have over what is enetered and where on the screen. It will allow you to enter great strings of garbage and completely ruin any screen where it is used with Redo prompts and other stuff. Worst, it is "blocking" which means nothing else runs while you are waiting for input.

Have a look at the below link. This is a replacemnet function I wrote decades ago (QB4.5), suitably tweaked for MMBasic.

It allows you to start with a string and edit it (start with "" if you want to emulate INPUT) and you can limit the size and specify where it happens on the screen. Although not in this version, I have tweaked it in the past to limit input to specified characters (number only or "Y", "N", or "C" etc) and you could take it as far as you want to format the text returned so it is all upper or lower case etc... sky's the limit. As written here, it works with the serial console and uses ANSI control sequences to position the cursor etc. you might wanna tweak that how you see fit

StrEdit$()

might help or provide inspiration.
 
EDNEDN
Senior Member

Joined: 18/02/2023
Location: United States
Posts: 128
Posted: 09:09pm 26 Mar 2025
Copy link to clipboard 
Print this post

  Frank N. Furter said  Okay, then I probably have to read in individual characters with INKEY$ until a RETURN occurs in order to be able to read in a “,”?

@Volhout:
To be honest - I had never paid attention to the “,” in INPUT$ before    - I had never needed it in a string...



Frank...    Take a look at:

LINE INPUT [prompt$,] string-variable$

Reads an entire line from the console input into ‘string-variable$’.
‘prompt$’ is a string constant (not a variable or expression) and if specified
it will be printed first. A question mark is not printed unless it is part of
‘prompt$’. Unlike INPUT, this command will read a whole line, not
stopping for comma delimited data items. A question mark is not printed
unless it is part of ‘prompt$’

You will get the whole line of characters (including any commas).   You will have to parse the string to separate the fields in a meaningful way.   But that is the typical way to handle things.    And of course, LINE INPUT #1  works with an open file too.
Edited 2025-03-27 07:16 by EDNEDN
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 935
Posted: 07:39am 27 Mar 2025
Copy link to clipboard 
Print this post

Thank you very much for your suggestions. In the meantime I have realized a solution with INKEY$, but I think that LINE INPUT is the better choice!

Thank you very much for your help! (...I love this forum...)

Frank
 
EDNEDN
Senior Member

Joined: 18/02/2023
Location: United States
Posts: 128
Posted: 12:30pm 27 Mar 2025
Copy link to clipboard 
Print this post

  Frank N. Furter said  In the meantime I have realized a solution with INKEY$, but I think that LINE INPUT is the better choice!


It all depends on what you need.   If you just want quick and easy, LINE INPUT is probably the right answer.    But if you need to handle the information coming in dynamically, INKEY$ might be better.

For example...    If you need to honor a kill character or some other status character that will immediately return some status information about the connection, INKEY$ will be a better choice because you don't give up control of the input processing to the interpreter.   Your program gets to look at each character as it is coming in and make a decision of what to do with it.
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 935
Posted: 01:02pm 27 Mar 2025
Copy link to clipboard 
Print this post

@EDNEDN:

THANK YOU! I have tried it out. LINE INPUT does exactly what I want and need.

Frank
 
Print this page


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

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025