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:
PRINT "Press <ANY KEY> to continue!"
Note: There should already be a very useful set of code inside header_stub.bas which looks like:
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:
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:
CONST True
= -1, False
= 0
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.