Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unused routines still result in huge .EXE
#20
(08-07-2024, 01:10 AM)SMcNeill Wrote: My way of dealing with huge routines is to wrap them inside precompiler blocks.


Code: (Select All)
$IF CENTER_TEXT_USED THEN
    SUB CenterText(x$, where)
       'centering routine
    END SUB
$END IF


Now, I can include that source in any other program of mine, for use basically as a library file, and it's NOT going to get added to the compiled EXE.  It's going to be skipped over and excluded by default.

IF I want to make use of that routine, I'd need to add one line to the top of my source:

Code: (Select All)
$LET CENTER_TEXT_USED = TRUE 

I've set my routines to be excluded by our built in precompiler, until we specifically specify to include them in our source.  This method ensures that ONLY the code I need is included in my EXE, making it as small as possible with QB64PE.
Ok, I've been playing around with this today and the possibilities are now swirling around in my head.

But, many of them are not possible because $LET is always seen. What is really needed is this:

$IF CENTER_TEXT_USED THEN
    $LET MIN_MAX_USED = TRUE
    SUB CenterText(x$, where)
        'code
        'code
        'a = MinMax(b, c)
    END SUB
$END IF

The $LET statement above needs to be ignored until the $IF...$END IF becomes true. Now the possibilities become increasingly interesting.

OH HOLD THE PHONE!

I must have been doing something wrong, this does in fact work!
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply


Messages In This Thread
RE: Unused routines still result in huge .EXE - by TerryRitchie - 08-09-2024, 07:25 PM



Users browsing this thread: 2 Guest(s)