Author Topic: another question about line input  (Read 4288 times)

0 Members and 1 Guest are viewing this topic.

Offline badger

  • Forum Regular
  • Posts: 148
    • View Profile
another question about line input
« on: October 04, 2020, 03:30:15 pm »
Hello

Sorry to post so many questions but i have not use qb since the 90s. This new version has some things i dont even know are there...

Question is there any way to trap chr$(13) <enter> from a line input
as far as i know you cant

Badger

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: another question about line input
« Reply #1 on: October 04, 2020, 03:34:00 pm »
Trap it from it?  CHR$(13) is the ENTER key, and designates the end of input; it’s not included in the input itself.

What exactly are you attempting/wanting to do?
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline badger

  • Forum Regular
  • Posts: 148
    • View Profile
Re: another question about line input
« Reply #2 on: October 04, 2020, 03:39:54 pm »
Hello

I am using only one input in my program. I do not want the ? mark that input puts in. So when the user hits enter the input sr should have the value of chr$(13) instead line input used the enter to end the string. so here is what i want to do

if a$=chr$(13) then do something else

Badger

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: another question about line input
« Reply #3 on: October 04, 2020, 03:51:31 pm »
Sounds like you want INKEY$ (the old way) or _KEYHIT the new way or _KEYDOWN for key combos.

FellippeHeitor

  • Guest
Re: another question about line input
« Reply #4 on: October 04, 2020, 04:11:37 pm »
On the other hand, if the variable is empty, that means the user just pressed enter.

Offline badger

  • Forum Regular
  • Posts: 148
    • View Profile
Re: another question about line input
« Reply #5 on: October 04, 2020, 04:18:19 pm »
Hello

@FellippeHeitor
that is try but i am unable to trap that condition in a case statement any suggestions


this is a condition i sorta need to fix .. i dont like to have loop holes in my programs LOL

Badger

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: another question about line input
« Reply #6 on: October 04, 2020, 04:45:11 pm »
Hello

@FellippeHeitor
that is try but i am unable to trap that condition in a case statement any suggestions


this is a condition i sorta need to fix .. i dont like to have loop holes in my programs LOL

Badger

No fix needed, if the variable comes back empty = "" then <enter> is all that was pressed (for LINE INPUT or just INPUT)

Code: QB64: [Select]
  1. LINE INPUT "prompt ", var$ ' <<<<<<<<<< notice no ?
  2. IF var$ = "" THEN PRINT "You just pressed <enter>."
  3.  
  4.  
  5.  

Offline badger

  • Forum Regular
  • Posts: 148
    • View Profile
Re: another question about line input
« Reply #7 on: October 04, 2020, 04:55:26 pm »
Hello

Gee that worked i must have done something wrong LOL i will go back and check and see

I guess that was a dumb question

Thanks a lot for your response

Badger

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: another question about line input
« Reply #8 on: October 04, 2020, 05:06:00 pm »
So here, try this:
Code: QB64: [Select]
  1.         CASE CHR$(88): RETURN 'X
  2.         CASE CHR$(45): GOTO inv6 '-
  3.         'CASE CHR$(13): GOTO s1 ' enter key or ""
  4.          CASE "" : GOTO s1  '<<<<<<<<<<<<<<<<<<<<<<<<< try for just enter on LINE INPUT
  5.         CASE ELSE
  6.                 GOSUB custinforec_null
  7.                 custinforec.id = sr
  8.                 GOSUB inv0
  9.                 GOTO s2
  10.  
  11.  

Offline badger

  • Forum Regular
  • Posts: 148
    • View Profile
Re: another question about line input
« Reply #9 on: October 05, 2020, 11:30:45 am »
Hello

I am so embarrassed i figured out why that was not working.. i had left out a gosub so sr was equal to the value it received when from the main menu which was 1. so i figured that out and all is fine thanks so much for your the help i received. i cant get over what i did LOL.  i am sorta cleaning up some code going from a bunch of if/then to  case i cut to much.

Badger

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: another question about line input
« Reply #10 on: October 05, 2020, 11:38:27 am »
Me, I have 1 - 3 stupid blunders a day usually. @!%# Why isn't this working... oh!

Offline badger

  • Forum Regular
  • Posts: 148
    • View Profile
Re: another question about line input
« Reply #11 on: October 06, 2020, 02:23:54 pm »
Hello

Yes that is exactly what happened .. just sorta look at another spot that worked and there it was ok should have had a v8

lol

Badger