![]() |
Forum Index : Microcontroller and PC projects : Problem with INPUT A$ and '',''
Author | Message | ||||
Frank N. Furter Guru ![]() Joined: 28/05/2012 Location: GermanyPosts: 936 |
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 KingdomPosts: 10063 |
, is the input separator manual page 116 |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 4853 |
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: GermanyPosts: 936 |
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 ![]() Frank |
||||
twofingers Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1526 |
Hi Frank, or Line Input? Regards Michael causality ≠ correlation ≠ coincidence |
||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2137 |
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 StatesPosts: 128 |
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: GermanyPosts: 936 |
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 StatesPosts: 128 |
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: GermanyPosts: 936 |
@EDNEDN: THANK YOU! I have tried it out. LINE INPUT does exactly what I want and need. Frank |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |