• Print

Author Topic: supression of line feeds  (Read 222 times)

elmo533940

  • Newbie
  • *
  • Posts: 12
    • Email
supression of line feeds
« on: September 20, 2012, 06:50:07 PM »
The following section of code always scrolls the screen rather than changing the prompt line. I have exhausted my meager knowledge on how to stop the line feed and scroll.  This happens whether I use the 0.945 compiler or the 0.955_gl compiler. Any suggestions?

COLOR 14, 0: LOCATE 29, 2 '          place dursor at beginning of prompt liine
PRINT "Enter a name to search for... "; 'print prompt on screen
COLOR 15, 0: INPUT "", name$ '       get search name from user
LOCATE 29, 2: PRINT SPC(78); '       erase previous prompt
n$ = UCASE$(name$) '                 convert search name to upper case
COLOR 14, 0 '                        change foreground color to yellow
LOCATE 29, 2: PRINT "Searching..."; 'print message

TerryRitchie

  • Hero Member
  • *****
  • Posts: 2269
  • FORMAT C:\ /Q /U /AUTOTEST (How to repair Win8)
    • Email
Re: supression of line feeds
« Reply #1 on: September 20, 2012, 07:01:17 PM »
The snippet of code you provided works fine for me. Must be something happening before, or after, this code.  Can you supply more of the code to review?

Clippy

  • Hero Member
  • *****
  • Posts: 16446
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: supression of line feeds
« Reply #2 on: September 20, 2012, 07:10:11 PM »
Row 29 was a dead giveaway:

Code: [Select]
SCREEN 12

COLOR 14, 0: LOCATE 29, 2 '          place dursor at beginning of prompt liine
PRINT "Enter a name to search for... "; 'print prompt on screen
COLOR 15, 0: INPUT ; "", name$ '       get search name from user
LOCATE 29, 2: PRINT SPC(78); '       erase previous prompt
n$ = UCASE$(name$) '                 convert search name to upper case
COLOR 14, 0 '                        change foreground color to yellow
LOCATE 29, 2: PRINT "Searching..."; 'print message

You can put a semicolon after INPUT to keep the entry on the same line.
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

SMcNeill

  • Hero Member
  • *****
  • Posts: 2421
    • Email
Re: supression of line feeds
« Reply #3 on: September 20, 2012, 07:11:27 PM »
Is 29 the bottom of the screen?  The last 2 lines of any screen auto-scroll when printed on.  I've been thinking an $SCREENSCROLL:OFF command would be nice for some time now.
http://bit.ly/TextImage -- Library of QB64 code to manipulate text and images, as a BM library.
http://bit.ly/Color32 -- A set of color CONST for use in 32 bit mode, as a BI library.

http://bit.ly/DataToDrive - A set of routines to quickly and easily get data to and from the disk.  BI and BM files

TerryRitchie

  • Hero Member
  • *****
  • Posts: 2269
  • FORMAT C:\ /Q /U /AUTOTEST (How to repair Win8)
    • Email
Re: supression of line feeds
« Reply #4 on: September 20, 2012, 07:20:23 PM »
Row 29 is only about 2/3rds down my screen as provided by the snippet.

Clippy

  • Hero Member
  • *****
  • Posts: 16446
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: supression of line feeds
« Reply #5 on: September 20, 2012, 07:20:47 PM »
Not in SCREEN12. Limbo lower!  ;D

Code: [Select]
SCREEN 12

COLOR 14, 0: LOCATE 30, 2 '          place dursor at beginning of prompt liine
PRINT "Enter a name to search for... "; 'print prompt on screen
COLOR 15, 0: INPUT ; "", name$ '       get search name from user
LOCATE 30, 2: PRINT SPC(78); '       erase previous prompt
n$ = UCASE$(name$) '                 convert search name to upper case
COLOR 14, 0 '                        change foreground color to yellow
LOCATE 30, 2: PRINT "Searching..."; 'print message
SLEEP

« Last Edit: September 20, 2012, 07:47:38 PM by Clippy »
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

SMcNeill

  • Hero Member
  • *****
  • Posts: 2421
    • Email
Re: supression of line feeds
« Reply #6 on: September 20, 2012, 07:36:35 PM »
I'm thinking this is running in Screen 12 or 13, and is auto-scrolling the screen when ENTER is hit on the INPUT.

Try something like this, and see if it doesn't fix the problem:
Code: [Select]
SCREEN 12
COLOR 14, 0: LOCATE 29, 2 '          place dursor at beginning of prompt liine
PRINT "Enter a name to search for... "; 'print prompt on screen
COLOR 15, 0: name$ = GetInput$ '     get search name from user
LOCATE 29, 2: PRINT SPC(78); '       erase previous prompt
n$ = UCASE$(name$) '                 convert search name to upper case
COLOR 14, 0 '                        change foreground color to yellow
LOCATE 29, 2: PRINT "Searching..."; 'print message
SLEEP

FUNCTION GetInput$
DO
    a$ = INKEY$
    IF a$ <> "" AND a$ <> CHR$(13) THEN
        GetInput$ = GetInput$ + INKEY$
        PRINT a$;
    END IF
LOOP UNTIL a$ = CHR$(13)
END FUNCTION

By using INKEY$ to get our name$, we don't automatically move to the next line with a CRLF.  If this doesn't fix the problem, then we'll definitely need more code to figure out exactly what's going on.  I'm betting this will work for you though.  ;)

NOTE:  This GetInput$ function is a very weak function.  It offers no backspace, delete, arrow key support....  Any key press but Enter will add to the length of the name$, even backspace!  If this is what you're looking for, you'll want to error-trap the function to only support the keys that you want it to.
« Last Edit: September 20, 2012, 07:42:41 PM by SMcNeill »
http://bit.ly/TextImage -- Library of QB64 code to manipulate text and images, as a BM library.
http://bit.ly/Color32 -- A set of color CONST for use in 32 bit mode, as a BI library.

http://bit.ly/DataToDrive - A set of routines to quickly and easily get data to and from the disk.  BI and BM files

Clippy

  • Hero Member
  • *****
  • Posts: 16446
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: supression of line feeds
« Reply #7 on: September 20, 2012, 07:48:44 PM »
INPUT ; "", name$
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

SMcNeill

  • Hero Member
  • *****
  • Posts: 2421
    • Email
Re: supression of line feeds
« Reply #8 on: September 20, 2012, 08:00:05 PM »
Quote from: Clippy on September 20, 2012, 07:48:44 PM
INPUT ; "", name$

Well what do ya know, that works too!   I guess you can learn something new every day.  ;)

To be honest, I don't really use INPUT all that often, so I didn't know you could use the ; after the input like that.  Is this a QB64 feature, or did QBasic do the same?  I don't remember it working like this...
http://bit.ly/TextImage -- Library of QB64 code to manipulate text and images, as a BM library.
http://bit.ly/Color32 -- A set of color CONST for use in 32 bit mode, as a BI library.

http://bit.ly/DataToDrive - A set of routines to quickly and easily get data to and from the disk.  BI and BM files

Clippy

  • Hero Member
  • *****
  • Posts: 16446
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: supression of line feeds
« Reply #9 on: September 20, 2012, 08:45:36 PM »
QB used it too. It was something I missed for a long time too. Enter takes you to the next row without it. Then row 29 and 30 scroll in SCREEN 12. That's how I guessed the problem was in that screen, my favorite in QB.
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

elmo533940

  • Newbie
  • *
  • Posts: 12
    • Email
Re: supression of line feeds
« Reply #10 on: September 22, 2012, 04:07:07 PM »
The trick, it seems is in kn owing WHERE to put the semicolon. Thanks for the heads up on this. It solved the problem. It is nice having a decent BASIC to program with. The last one I had was Borland's TurboBASIC. I am a very amateur programmer at best. I have attached, or will try to attach the .bas program that this problem occurred in. Again many thanks.

  • Print