QB64 Phoenix Edition
DAY 034: WIDTH (SUB) - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: Official Links (https://qb64phoenix.com/forum/forumdisplay.php?fid=16)
+--- Forum: Learning Resources and Archives (https://qb64phoenix.com/forum/forumdisplay.php?fid=13)
+---- Forum: Keyword of the Day! (https://qb64phoenix.com/forum/forumdisplay.php?fid=49)
+---- Thread: DAY 034: WIDTH (SUB) (/showthread.php?tid=1276)



DAY 034: WIDTH (SUB) - SMcNeill - 12-14-2022

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


RE: DAY 034: WIDTH (SUB) - vince - 12-14-2022

oh nice, Keyword of the Day is particularly well written today, good improvements.  Not to be confused with (underscore) _WIDTH, though some people think _HEIGHT is more important


RE: DAY 034: WIDTH (SUB) - mnrvovrfc - 12-14-2022

Thank you for this. After looking enough at the "CMD.EXE" window on Windows10 long enough, and being able to set it to a ridiculous amount of lines, which would have been impossible under MS-DOS, I should have asked myself, "Gee whiz, only if the QB64 'mainwin' supported something like this. Even if it just calls that console and can't do SCREEN 0 anymore, it would be cool." Well, I regain Internet access this year to discover something else that wasn't in Galleon's QB64. :tu:


RE: DAY 034: WIDTH (SUB) - Pete - 12-14-2022

(12-14-2022, 04:20 PM)vince Wrote: oh nice, Keyword of the Day is particularly well written today, good improvements.  Not to be confused with (underscore) _WIDTH, though some people think _HEIGHT is more important

Big Grin Big Grin Big Grin  @ _HEIGHT. +1


RE: DAY 034: WIDTH (SUB) - Pete - 12-14-2022

Roseanne Roseannadanna has this to add about WIDTH...

Have you ever noticed when you open a window with WIDTH 25, 25 you get a nice teeny tiny square black window, and then you go to print something only to find what you print ends up in an ugly big ASCII font! Why do we have to put up with a big ASCII font in our teeny tiny window? I tell you Jane, it's always something!

Well my little Roseanne Roseannadanna, you can have your teeny tiny window and a 16x16 font, simply by adding...

Code: (Select All)
WIDTH 25, 25
_FONT 16 ' <----------------
PRINT "SNL used to be good,"
PRINT "But now it SUCKS!"

Pete will be back tomorrow. Vacationing in Acapulco, on his KEYWORD OF THE DAY OFF. Big Grin