DAY 021: LOCATE - 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 021: LOCATE (/showthread.php?tid=1218) |
DAY 021: LOCATE - Pete - 12-02-2022 Since I'd rather code than write, I decided to present the KEYWORD of the Day, LOCATE in a brief demo. Reading the code window is also an easy option to obtain the various descriptions. Just press a key during a pause to move on... Code: (Select All) ' LOCATE Demo Now naturally I did this for SCREEN 0. If anyone wants to elaborate on the use of LOCATE in a graphics environment, feel free. Pete RE: DAY 021: LOCATE - SMcNeill - 12-02-2022 Before I do much explaining, copy and run the code below so you can see what I'm talking about for yourself: Code: (Select All) Screen _NewImage(800, 600, 32) Now, LOCATE works *EXACTLY* the same in graphics mode as it does in Pete's SCREEN 0 example -- *as long as you're dealing with a monospace font*! Font F, in the example above, is monospaced and thus locates 10 rows down and 10 columns over. It starts printing just where we'd expect to see it. Font F1, on the other hand, is a variable-width font (we didn't specify the "monospace" tag with it), and as such, it has a _FONTWIDTH of 0 (ZERO!). There's no way we can figure out where to put the font in regards to the "10th column of text", as it's variable width. 10th column of what?? i's or W's? When the w's of many variable width fonts are easily twice the width of the i's, you can't know where the 10th column of anything is going to be -- the 10th letter of your text will start wherever the width of the previous 9 characters place it! So how does LOCATE work with variable width fonts?? It still locates by ROW, which is why the !! in that LOCATE 11, 10 ends up placing us exactly one line below the LOCATE 10, 10 we used previously. The difference is, it no longer locates by COLUMN, but instead by PIXEL. For a fixed width (monospace) font, LOCATE works by ROW, COLUMN. For a variable width font (no monospace), LOCATE works by ROW, PIXEL. And that's basically the difference in LOCATE with a graphical environment, verses a SCREEN 0 environment. In SCREEN 0, one doesn't have to worry about how locate acts with variable width fonts, as they're simply not allowed in screen 0 to begin with. It's only in graphic modes, and with non-monospaced fonts, that one has to remember that LOCATE works by ROW, PIXEL. In all other cases, it work via ROW, COLUMN. RE: DAY 021: LOCATE - mnrvovrfc - 12-02-2022 "Try doing that with LOCATE," said a mini-mod of the oldest forum. Now I'm trying to think about why he said it... OK I'm giving the game away. I shared a game program that I wrote on QuickBASIC, kept it at the "tiny" 320x200 but it was mostly text mode anyway. The time hasn't arrived yet where I tell you what was my username in Galleon's forum and other things about it. Hmmm did some of you look for "Discussion" posts in the large number of pages of the old QB64 Wiki? Some of it was entertaining, very surprising coming in one half from somebody who later became very important... Umm, erm, ahh... the third parameter of "LOCATE" is more useful now in Freebasic than in QB64, because the other programming system takes up the terminal that an user program is run in, assuming it's not a "GUI" program. Not like QB64 "SCREEN 0" nor like "$CONSOLE:ONLY" mode. A few people would request the fourth and fifth parameters honored only to keep freaking out at the moving hamburger... (12-02-2022, 05:41 AM)SMcNeill Wrote: And that's basically the difference in LOCATE with a graphical environment, verses a SCREEN 0 environment. In SCREEN 0, one doesn't have to worry about how locate acts with variable width fonts, as they're simply not allowed in screen 0 to begin with.Maybe I should spend far more time reading the wise people than babbling. |