Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DAY 034: WIDTH (SUB)
#1
I thought I'd be nice and post a word today, to give Pete a break for a bit.  (Also, someone asked me about this, and it's just as easy to write an answer here as it is elsewhere.  Big Grin)

WIDTH -- One of those simple little commands that has been in the language forever and ever.  Going back to the days of GWBASIC, one could always use WIDTH to set the character height and width of a SCREEN 0 screen.  You can see our wiki article on it here: https://qb64phoenix.com/qb64wiki/index.php/WIDTH

Usage has always been rather simple:  WIDTH columns, rows

One keyword, two parameters to set how many columns and how many characters you wanted to print to the screen.  Can't get much simpler than that, now can it??

So, someone asked me, "WHAT THE HECK ARE THE EXTRA TWO PARAMETERS THAT QB64PE ACCEPTS AFTER THAT???"  (And yes, I was asked in all caps, so you know this is a serious question!)

Let me answer this in two parts:

For our Linux and Mac users:  Those two parameters are nothing for you.  They do nothing.  Change nothing.  They're not implemented in either Linux nor Mac.  Set them to whatever you like, nothing is ever going to change.  (At least, not until someone goes in and makes them multi-platform compatible.  At the moment, they only apply for Windows.)

Sorry guys.  Sad

For our Windows users, those two parameters are used FOR THE CONSOLE ONLY.  Unless you use $CONSOLE in your program, they're not going to change anything at all for you either.  You might as well be using a Linux PC, as far as WIDTH and the 3rd and 4th parameter are concerned.

So...  You're a windows user.  Your program uses $CONSOLE.  What the heck does those last 2 parameters do for you?

They set the total width and height of your available console.

For example, let's try the following program:

Code: (Select All)
$Console:Only
Width 50, 50, 500, 500
ten$ = "0123456789"
For i = 1 To 50
    Print ten$;
Next
sleep

 
Now, if you look, you'll see that I'm printing 10 characters to the screen 50 times -- and they're all printed on the same line.  (semicolon at the end of the print keeps continuous printing without a new line, remember?)  

The Width 50, (who cares), (who cares), (who cares) says that my console is only going to be 50 columns in width.  That's the most characters that it can display on the screen at a single time.   Look at the console we created, count the number of ten$ you see on the screen -- it's exactly 5 of them.  First parameter is the number of visible characters.

BUT, if you look down at the bottom of the console, you'll see a scroll bar.  Go ahead and scroll it to the right.  If you took time to scroll and count, you'd see that the total width of our console is actually 500 characters!  We set that with the 3rd parameter:  Width (who cares), (who cares), 500, (who cares)

It's the same with our height and total height as well.  The second parameter says that we're only going to display 50 rows of text on the screen at any given time, but the 4th parameter says that we're going to have 500 rows total, before we start scrolling up the bottom and losing information off the page.

WIDTH, with its 4 parameters, in Windows Console is:

WIDTH columns visible, rows visible, total columns, total rows.

If you set the 3rd and 4th parameters to be the same as your 1st and 2nd, you can create a console with NO scroll bars -- everything that you're displaying is instantly viewable for your user.  

And that's what those two new "secret" little parameters do for us, in a nutshell.  Wink
Reply


Messages In This Thread
DAY 034: WIDTH (SUB) - by SMcNeill - 12-14-2022, 02:48 PM
RE: DAY 034: WIDTH (SUB) - by vince - 12-14-2022, 04:20 PM
RE: DAY 034: WIDTH (SUB) - by Pete - 12-14-2022, 07:34 PM
RE: DAY 034: WIDTH (SUB) - by mnrvovrfc - 12-14-2022, 04:47 PM
RE: DAY 034: WIDTH (SUB) - by Pete - 12-14-2022, 07:49 PM



Users browsing this thread: 1 Guest(s)