Author Topic: "Hidden Secrets" of QB64 (AKA Things people never seem to use)  (Read 4846 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
"Hidden Secrets" of QB64 (AKA Things people never seem to use)
« on: November 06, 2019, 05:49:18 am »
Over time, we've pushed a lot of changes into QB64 from its initial creation waaaay back in the day, to today, and a lot of those changes seem to never be used or highlighted by anyone here on the forums -- so I thought I'd dedicate a topic to what I think are some of the more powerful, and most underused/under-documented capabilities of QB64.

Richard's post here (https://www.qb64.org/forum/index.php?topic=1839.0) is one which got me to thinking about these "hidden secrets", so let me start by expanding a bit upon what I told him, and explaining how it'd all work simply for someone.

Inside the QB64 folder structure, there's two BAS files buried in the "source\embed\" folder called header_stub.bas and footer_stub.bas.  Except for my own personal use, I've never heard of anyone using these two files.

"What are header_stub.bas and footer_stub.bas, and what can they do," you ask?

Simply put, they're a set of custom $INCLUDE files which will go automatically to the top and the bottom of *ALL* your code.

Have a nifty little company logo which you want to always display at the start of any program you write?  Code it into header_stub.bas and it'll be added automatically to all your compiled programs.

Here, let's try it!!  Just follow the steps below and see what happens.

1) Open your QB64 folder, wherever you have it saved.
2) Start QB64.bas.
3) Click the menu up top and click on FILE, then click OPEN
4) Navigate through the source/embed folder and select header_stub.bas and open it.
4a) If you have the current v1.3 stable build, the file is located at: source\virtual_keyboard\embed

source\embed -- is where it's at with the current development build -- this is also what you get if you download the repo manually.

5) Add the following code to the blank bas program which you just opened:

Code: QB64: [Select]
  1. PRINT "Made by STEVE!"
  2. PRINT "Press <ANY KEY> to continue!"

Note: There should already be a very useful set of code inside header_stub.bas which looks like:

Code: QB64: [Select]
  1. 'blank line    

Just paste the code above below that placeholder segment, if you will.

6) Save that file.  There's no need to compile it; just save it.
7) Now click on the menu and select FILE, then NEW
8) Write the most common line that any programmer ever seems to code with a new programming language:

Code: QB64: [Select]
  1. PRINT "Hello World"

9) Compile and run that code.

Congratulations!  All your programs will now start up with a screen which says Steve made them.  You can now send me royalties for all the hard work I did modifying and improving all your programs!  ;D

(Or you can just reopen header_stub.bas and delete those changes, if you want.)



Anything placed in header_stub.bas will go into the top of any program you compile, forever more.   Anything placed in footer_stub.bas will go into the bottom of any program you compiler, forever more.  (At least from the QB64 folder which you made the changes to header_stub and footer_stub.  Note that these are only LOCAL enhancements and won't be available for programs you share via the forums or compile from a different folder, or on a different PC.)

If you're curious about some very useful little commands which I tend to place inside my header_stub.bas and footer_stub.bas, here's what I often use for my personal programs:

header_stub.bas:

Code: QB64: [Select]
  1. CONST True = -1, False = 0
  2. DEFLNG A-Z

footer_stub.bas, I really don't do very much with, though I have tossed some of my toolbox routines in there in the past, just to keep them out of cluttering up my main programs, such as the SUB Sort, or FUNCTION ExtendedTimer...  I just use it as a quick way to add expanded functionality to all my programs for usage.

The only issue with modifying these folders is that the changes are local to only the version of QB64 which has the changes made to it.  If I share code on the forums which I write, I have to remember to set a CONST for True/False and all of the above into the code manually.  Failure to do so will have someone trying to test the code and then complaining, "You're a big dummy.  You didn't set your CONST, or didn't DIM your mem block".  I did -- I was just a big dummy who forgot I only did so locally....

header_stub.bas and footer_stub.bas have to be two of the most powerful things one can use to expand and customize usability of QB64, and yet I've never heard of anyone else ever using it, so I thought I'd highlight their existence as the first "hidden secret of QB64".

Other secrets to be added into this topic/post, as they come to my attention and I have time to sit down and write them up to help bring them to people's awareness.  Feel free to add your own little "hidden secrets", or "seldom used things in QB64" into this topic as well.  QB64 has a lot of power and functionality to it, and a lot of that customization ability is simply overlooked or underutilized by most people.  Let's use this topic to help raise awareness of some of those extra little features.

(And don't forget to go in and edit your header_stub.bas, unless you just want all your programs to say, "Created by Steve", forever more.)  :D

Edit: Updated file position for the current version 1.3.
« Last Edit: November 06, 2019, 01:36:27 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: "Hidden Secrets" of QB64 (AKA Things people never seem to use)
« Reply #1 on: November 06, 2019, 06:03:56 am »
Secret #2: Did you guys know this trick?

1) Start up QB64
2) Click on the Menu, select HELP, then ASCII chart.

At this point, you can click on the chart and quickly insert any ASCII character directly into your code.

(I imagine most folks knew this, as this is an often used feature by many people.)

But the question is: Did you know that you could hit the space bar to toggle between the code and its value with that ASCII chart?

Just try it for yourself!

Don't know what the ASCII value of "A" is??  Open the menu, select help, click on the ASCII chart, and find the "A" on it.  (5 down, 2 across.)  Hit the space bar -- the display now reads the numeric values!!

Of course, you can also just scroll the mouse around and let it blink as it toggles between the values and symbols of one individual ASCII code -- but that's obvious and not something which people overlook.   Very few people bother to hit the spacebar and actually toggle modes in the ASCII chart, which is why it's a "hidden secret" of QB64.  :P
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: "Hidden Secrets" of QB64 (AKA Things people never seem to use)
« Reply #2 on: November 06, 2019, 10:57:28 am »
Good topic Steve!

If I don't have /embed sub-folder under /source, I could just make it and make the files you mentioned in OP?

Ha! I was just looking at  McFreyer's post and trying to figure CHR$(43) and CHR$(45) which turn out to be + and - but for some reason they didn't work when first tried...  anyway if I remembered the ASCII chart that would have been handy!

Things have to be practiced on regular basis for them to stick in memory, which explains why I haven't gone back to Inform, I've forgotten all that I had learned and would have to start over.

Some forums have sticky posts that always stay on top, this might be a good sticky topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: "Hidden Secrets" of QB64 (AKA Things people never seem to use)
« Reply #3 on: November 06, 2019, 11:09:32 am »
Good topic Steve!

If I don't have /embed sub-folder under /source, I could just make it and make the files you mentioned in OP?

If you don’t have them, QB64 will bug out and go “IDE Module Error!” (or something similar).

Look for the source folder in the main QB64 directory; don’t get it confused with the one in the internal/source folder.

Edit: Look for QB64.bas.  The embed folder is in the same source directory as it.  ;)
« Last Edit: November 06, 2019, 11:11:33 am by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: "Hidden Secrets" of QB64 (AKA Things people never seem to use)
« Reply #4 on: November 06, 2019, 11:39:08 am »
Here is what I am looking at:
  [ You are not allowed to view this attachment ]  

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: "Hidden Secrets" of QB64 (AKA Things people never seem to use)
« Reply #5 on: November 06, 2019, 12:34:57 pm »
Here is what I am looking at:

Aha!  The file location has changed from some of the changes we've been pushing into the development build.   header_stub.bas and footer_stub.bas have been a part of QB64 for ages, but the location of the file has changed slightly in the last few months.

qb64\source\virtual_keyboard\embed -- here's where it's at with the v1.3 version.
qb64\source\embed -- he's where it's at with the current development build -- this is also what you get if you download the repo manually.

I had to download the latest stable build to find where the file was located.  My apologies for the confusion.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: "Hidden Secrets" of QB64 (AKA Things people never seem to use)
« Reply #6 on: November 06, 2019, 01:18:06 pm »
Yep, there it is! Thanks Steve

I did look in other folders but failed to imagine it might be under virtual keyboard.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: "Hidden Secrets" of QB64 (AKA Things people never seem to use)
« Reply #7 on: November 06, 2019, 01:28:40 pm »
Yep, there it is! Thanks Steve

I did look in other folders but failed to imagine it might be under virtual keyboard.

And that’s why I was completely baffled that it was missing, as well.  The virtual keyboard was part of the old android code which Galleon was working on, and was never fully implemented properly, so it was removed from the latest versions of QB64.  Like you, I never imagined that the files were hidden in that keyboard directory, and thus moved when it was removed.

It truly was a “Hidden Secret of QB64”!!
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline RhoSigma

  • QB64 Developer
  • Forum Resident
  • Posts: 565
    • View Profile
Re: "Hidden Secrets" of QB64 (AKA Things people never seem to use)
« Reply #8 on: November 06, 2019, 01:36:16 pm »
Just out of curiosity, what was the qb_framework stuff for? I know Galleon did mention it a couple of times over at [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there] while working on the early GL versions, but I never got the point of it.
My Projects:   https://qb64forum.alephc.xyz/index.php?topic=809
GuiTools - A graphic UI framework (can do multiple UI forms/windows in one program)
Libraries - ImageProcess, StringBuffers (virt. files), MD5/SHA2-Hash, LZW etc.
Bonus - Blankers, QB64/Notepad++ setup pack

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: "Hidden Secrets" of QB64 (AKA Things people never seem to use)
« Reply #9 on: November 06, 2019, 01:44:13 pm »
Just out of curiosity, what was the qb_framework stuff for? I know Galleon did mention it a couple of times over at [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there] while working on the early GL versions, but I never got the point of it.

If you remember, before Galleon disappeared from the project, he’d posted a few teasers about adding support for JSON format data.  That was basically the qb_framework stuff.  Like Android support, it was never fully implemented and has thus been removed from QB64.

If you open the old framework global file, you’ll see stuff like:

'#################### __JSON: Global ####################
CONST QB_JSON_STRING& = 1
CONST QB_JSON_NUMBER& = 2
CONST QB_JSON_BOOL& = 3
CONST QB_JSON_NULL& = 4
'http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf
'\b  Backspace CHR$(8)
'\f  Form feed CHR$(12)
'\n  New line CHR$(10)
'\r  Carriage return CHR$(13)
'\t  Tab CHR$(9)
'\"  Double quote CHR$(34)
'\\  Backslash caracter CHR$(92)
DIM SHARED __QB_JSON_escape_lookup(255) AS LONG
__QB_JSON_escape_lookup(8) = ASC("b")
« Last Edit: November 06, 2019, 01:46:08 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

FellippeHeitor

  • Guest
Re: "Hidden Secrets" of QB64 (AKA Things people never seem to use)
« Reply #10 on: November 06, 2019, 01:45:18 pm »
Json-like data serialization.

Offline RhoSigma

  • QB64 Developer
  • Forum Resident
  • Posts: 565
    • View Profile
Re: "Hidden Secrets" of QB64 (AKA Things people never seem to use)
« Reply #11 on: November 06, 2019, 02:05:59 pm »
Ahh yes, without all these unfinished things lurking around (JSON,Cloud,Android), the QB64 source got a bit tidier now. By the way the include lines for the qb_framework files are still in qb64.bas, of course in an deactivated form to avoid errors in the build process. Maybe these lines should be deleted completely, or are there plans to reactivate it any time?
My Projects:   https://qb64forum.alephc.xyz/index.php?topic=809
GuiTools - A graphic UI framework (can do multiple UI forms/windows in one program)
Libraries - ImageProcess, StringBuffers (virt. files), MD5/SHA2-Hash, LZW etc.
Bonus - Blankers, QB64/Notepad++ setup pack

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: "Hidden Secrets" of QB64 (AKA Things people never seem to use)
« Reply #12 on: November 06, 2019, 02:11:07 pm »
Ahh yes, without all these unfinished things lurking around (JSON,Cloud,Android), the QB64 source got a bit tidier now. By the way the include lines for the qb_framework files are still in qb64.bas, of course in an deactivated form to avoid errors in the build process. Maybe these lines should be deleted completely, or are there plans to reactivate it any time?

I think most of these have been removed completely.  You shouldn’t see them in the next version of QB64.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!