Make
Attachment:
GetFile.aspx?Page=MMBasic.Make&File=make.zipMake allows you to combine several source files into one, large BAS program.
This serves two purposes:
- You can split up parts of your program into separate files to make them easier to maintain. (For example: screen I/O code in one file, business logic in another).
- You can create different versions of your program for different platforms. For example, you can include graphics statements in the Colour Maximite version, terminal commands in the DOS version, and ANSI escape sequences for devices without a screen.
Instructions
There are three control arrays in MAKE.
- Platform is the list of platforms your makefile supports. Create a new entry in Platform for each distinct version you have to code for. (For example, Micromite, Colour Maximite, DOS)
- Target contains the output filenames for each platform. Each platform outputs to one BAS file.
- Source contains the source files for each platform. This is a two dimensional array; the first dimension is the platform number. The second is the file in that platform.
Let's add a third platform named "Microboard"; this will be a text-only version for headless microcontroller boards.
First, change Platform.Count to 3.
Add a new Platform and Target:
Platform(3)="Microboard"
Target(3)="MyProgMb.bas"
Now move down to the Sources section and add a new source:
'Microboard sources
Source(2,1)="MyProg Intro.bas"
Source(2,2)="MyProg UI Mboard.bas"
Source(2,3)="MyProg Main.bas"
Finally, you'll want to split out your code across these files. UI and platform dependent code would go in "MyProg UI {platform}.bas". Use "MyProg Intro.bas" for your Copyright notice and variable declarations, and use "MyProg Main.bas" for the main body of your program. Notice that only the second filename is different, so this is the only one you will modify when porting your program to an additional platform.
Future Plans
I will probably smarten this up a little bit more, for example to template filenames and make it faster and easier to add additional files. I may also add #if and #include directives.
License
Use this as you wish. No rights or restrictions are reserved. I ask only that you keep the original attribution at the top of the program.