Using+the+built-in+program+cruncher

//by Jon Ripley, April 2007//

The //BBC BASIC for Windows// compiler provides four functions to rewrite programs before compilation, these options are:


 * Discard spaces
 * Concatenate lines
 * Remove REMarks
 * Abbreviate names

The only way to apply these options to your code is to compile the program, however once the program is compiled there is no simple way to load the crunched program from the executable back into the editor.

Using the following technique it is possible to use the compiler to crunch your programs and save them in a way that they can be loaded back into the editor. This is achieved by making the compiled program save a copy of itself. Note that certain crunch options and combinations thereof can render programs uneditable. Always keep a backup of your original source code.

To crunch a program the copy and paste the following two lines at the start of your program: code format="bb4w" OSCLI"Save """+FNVif93Ux+""" "+STR$~(PAGE+?PAGE+?(PAGE+?PAGE))+" "+STR$~TOP:QUIT DEF FNVif93Ux=@dir$+"Crunched.bbc" code Once these lines have been added at the very start of the program choose the compile option from the tool bar or the Utilities menu of the BBC BASIC for Windows editor. Set the crunch options you want to be applied to your code and compile the program.

Now run the compiled executable to recover the crunched version of the program.

By default the crunched program will be saved as Crunched.bbc in the same directory as the compiled executable. To change the name or location of the saved file change **@dir$+"Crunched.bbc"** in the second line to point to where you want the file to be saved. If you change the file name be careful not to overwrite your original program.