Author Topic: Encountered some odd syntax for WIDTH statement that I do not understand  (Read 3409 times)

0 Members and 1 Guest are viewing this topic.

Offline hanness

  • Forum Regular
  • Posts: 210
    • View Profile
I was reviewing some really old code that I have and came upon something odd. Take a look at this small sample:


$Console:Only
_Dest _Console: _Source _Console

Width 70, 44
Width 70, 44, 70, 44


What looked odd to me was the fact that I have two width statements in a row. Further, the 2nd width statement lists the number of rows and columns twice. When I bring up the help for the width statement, there is no indication of this odd syntax. For the life of me I can't recall where I got that syntax or precisely what it does, but from experimentation here is what I found:

If I comment out either the 1st or the 2nd statement, then my screen is opened with vertical and horizontal scroll bars.
With both statements in place, the scroll bars are eliminated. This is the behavior that I want so clearly I put this there on purpose.

Could someone enlighten me as to what exactly the the syntax of the 2nd statement does and what the parameters denote?

Also, as a suggestion for the future, could this syntax be added to the help for the "width" statement?

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
WIDTH X, Y, Console_Width, Console_Height

The X sets your maximum number of visible columns.
The Y sets your maximum number of visible rows.
The Console_Width sets the width of your console screen.
The Console_Height sets the height of your console screen.

WIDTH 30, 30 will give you a 30x30 console screen.
WIDTH 30, 30, 60, 60 will give you a 30x30 display, but a 60x60 console which you can scroll left/right, up/down to view various portions of.

The last 2 parameters are windows only, and console only, but they allow you to set the max buffer for the console to interact with your scrollbars.

WIDTH 30, 30, 60, 60 gives you a 60x60 area to print to, with a 30x30 screen visible.
WIDTH 30, 30, 90, 90 gives you a 90x90 area to print to, with a 30x30 screen visible.

Edit:  This is all from memory, so I may have my numbers inverted.  The first x,y might be console and second buffer, or vice-versa...  My brain can’t sort out which actually sets the active display and which is the scroll bars, at the moment.  :P
« Last Edit: March 27, 2021, 02:51:56 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline hanness

  • Forum Regular
  • Posts: 210
    • View Profile
Excellent. Thanks.

Just out of curiosity, why do I need both lines (2 seperate "width" statements) to get rid of the scroll bars?

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Excellent. Thanks.

Just out of curiosity, why do I need both lines (2 seperate "width" statements) to get rid of the scroll bars?

You don’t.  You just need the line with all parameters.  ;D
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline hanness

  • Forum Regular
  • Posts: 210
    • View Profile
Not when I run it. If I don't have both lines, then I get scroll bars.

Test case:

Windows 10 ver 20H2
QB64 64-bit 1.5 Mar 17, 2021 Dev build

Just to be totally clear:

If I use only the line with all 4 params, I get scroll bars. If I use only the line with 2 params, I get scroll bars. The only way not to get them is to have both lines in the program.



Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Not when I run it. If I don't have both lines, then I get scroll bars.

Test case:

Windows 10 ver 20H2
QB64 64-bit 1.5 Mar 17, 2021 Dev build

Just to be totally clear:

If I use only the line with all 4 params, I get scroll bars. If I use only the line with 2 params, I get scroll bars. The only way not to get them is to have both lines in the program.

I can confirm this:
  [ You are not allowed to view this attachment ]

QB64v1.5