Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Incongruence between PRINT; and LOCATE+ PRINT; on the 25th row of Screen 0
#1
Hi friends

here I discovered again hot water!!!
here the experience about PRINT in SCREEN 0 (standard 80 columns and 25 rows of text)

Be calm QB64pe duplicates QB4.5 and Qbasic in this behaviour , so the issue comes from the far past of Qbasic.

run the code and enjoy the experience:
Code: (Select All)

_Title "Incongruence of behaviour of  25th line of text in SCREEN 0 using PRINT;"
While s$ <> "Q"
    Locate 1, 1
    Print "Please choose 1 to test PRINT; mode " + Chr$(13) + "and 2 to test LOCATE & PRINT; mode" + Chr$(13) + "press q to quit program demonstration"
    s$ = UCase$(InKey$)
    If s$ = "1" Then
        GoSub PrintMode1
    ElseIf s$ = "2" Then
        GoSub PrintMode2
    End If
Wend
End

PrintMode1:
Cls
For a% = 1 To 25
    If a% = 25 Then Print a%; Else Print a%
    _Delay .2
Next a%
Sleep 2
Cls
Return

PrintMode2:
Cls
For a% = 1 To 25
    Locate a%, 1
    Print a%;
    _Delay .2
Next a%
Sleep 2
Cls
Return

I repeat that this code (adapted to Qbasic : no  instructions _delay and _Title) gives the same result in Qbasic under Dosbox!

Well you can see how you can print on the 25th row (the last at the bottom) without going ahead only if you use LOCATE before PRINT ;  otherwise you go ahead also if you use PRINT; and you don't go over the 80 characters for row!

Why this information is useful?

in a Q&A
Question:  How to print on the last row of text without going ahead?
Answer:  You must use Locate Lastrow, Column: Print SomethingToPrint;  (Be care that Lastcolumn - Column >=LEN(SomeThingToPrint)) [example LOCATE 25,10: PRINT "SomethingLessThanLastColumn"   REM 80-10 >= LEN( "SomethingLessThanLastColumn") --> 70>=27
Reply
#2
Quit complaining. At least your Prime Minister is a hottie! Think about those poor bastards in France and Canada.

QB last line printing was so much fun to deal with back in 1990-something. A real jaw dropper. Locate, using the semi-colon, etc. are all needed tools. Oh and did I mention, your PM is a hottie!?

Pete Big Grin
Reply
#3
Hi Pete
thanks for feedback

here a video on my hottie PM Italian PM by Crozza  (Mattarella against Musk)

coming back to incongruence between ";" of PRINT and going ahead of  printing cursor on the last bottom row of text
1. where do you think to be the mistake? Why a LOCATE can correct the position of printing cursor after the following PRINT operation?

2. do you think that Wiki pages need a correction about ";" and the last printable row of text on the screen?
PRINT
Quote:
  • Semicolon(Wink - specifies that the print cursor stops at the end of the printed expression and may append later expressions or prints. PRINT ; or PRINT ""; will stop cursor movement and append later prints. Ending semicolons can also stop screen roll.
Reply
#4
Quote:
  • Use semicolon ends on bottom 2 rows of the SCREEN mode used or the PRINT will roll the screen up.
Reply
#5
Note the very subtle change I've made to your code and run the following:

Code: (Select All)

_Title "Incongruence of behaviour of  25th line of text in SCREEN 0 using PRINT;"
While s$ <> "Q"
    Locate 1, 1
    Print "Please choose 1 to test PRINT; mode " + Chr$(13) + "and 2 to test LOCATE & PRINT; mode" + Chr$(13) + "press q to quit program demonstration"
    s$ = UCase$(InKey$)
    If s$ = "1" Then
        GoSub PrintMode1
    ElseIf s$ = "2" Then
        GoSub PrintMode2
    End If
Wend
End

PrintMode1:
Cls
For a% = 1 To 24
    If a% = 25 Then Print a%; Else Print a%
    _Delay .2
Next a%
Sleep 2
Cls
Return

PrintMode2:
Cls
For a% = 1 To 25
    Locate a%, 1
    Print a%;
    _Delay .2
Next a%
Sleep 2
Cls
Return


Now, if you look at your first FOR loop, I changed that to only print 24 numbers and not 25.
Run it and look closely at what happens to your screen....

If you're at the bottom TWO rows (24 or 25) and PRINT, the screen scrolls up!

With your code, you're printing the numbers 1 to 23 on the screen.
Then on 24, you're printing 24 and scrolling the screen up a line to see 2 to 24 on the screen.
Then on 25, you're printing 25 with a semicolon at the end, which prevents the screen scrolling so you're now seeing 2 to 25 on the screen.

It's not on the last line that you're seeing something odd; it's the natural result of printing on EITHER of the  last two rows and not ending your print statement with a semicolon to prevent the screen scrolling.

It's the exact same behavior as all the way back to GW basic, IIRC, and is certainly the same behavior that QB45 has.



Now, with that said, there's also some crappy old legacy method to print on those lines and suddenly change your font from font 16 to font 8, which then gives you 50 lines to text to deal with and not 25.   That's intentional as well, as off as that seems to.  A lot of this old behavior is just based on the legacy behavior of QB45 and how it performed in the past, so that we can stay compatible with old code.

My suggestion for an easy fix?  Just swap over to _PrintString or _UPrintString and then you won't have that issue to deal with, with screen scrolling, no matter where you print on your screen.
Reply
#6
@Steve
thanks for technical  information...
so scroll up starts at row before the last row!
and the correct code to gain the 25th line of text is this

Code: (Select All)

Cls
For a% = 1 To 25
    If a% < 24 Then Print a%
    If a% = 24 Then Print a%;
    If a% = 25 Then Locate 25, 1: Print a%;
    _Delay .2
Next a%

it always uses LOCATE!!

Ok you suggest to pass to the graphic managing of text...
so it is more flexible...
do you think that wiki must be corrected?
Reply
#7
Or you could code it this way, but it still requires locate....

Code: (Select All)
Cls
For a% = 1 To 25
    Print a%;: If CsrLin < _Height Then Locate CsrLin + 1, 1
    _Delay .2
Next a%
Sleep


Just don't go past the screen height with that one.

Oh, did I mention your PM is a hottie?

Pete Big Grin
Reply




Users browsing this thread: 2 Guest(s)