Hi,
I appreciate that this is going to be a little bit of a nerdy computer programmer issue so please completely ignore this if you have no interest in compiling the open source Templot code, OpenTemplot or TemplotMEC.
Having started to go through some of the open source Templot code I would like to suggest that we start using "compiler directives" in any development. I really do think this will make things much simpler and it will allow the same code to be used in all versions without any modification. To allow this we need to agree on a naming convention to use hence this suggestion. However I'm more than happy to change it if it doesn't suit.
So what am I talking about "compiler directives"?
A little bit of background - at the moment Martin has released 2 different open source versions of Templot, namely OpenTemplot and TemplotMEC. To distinguish between the 2 different versions in the code Martin has programmed it in to show different colours and image on the control pad depending on what version you are running. If you look at the code this is set according to the Application Title, to set the colour it has a statement that says if Application.Title = 'TemplotMEC' then set the colour to one value otherwise set it to a different value. The issue that I can forsee is that if a user downloads the code and decides that he wants to change the title of the application then it will break the code.
With compiler directives we can define a flag that states which version we are compiling in one simple file.
What does this mean in practice?
Basically within the project we can include a file, I have decided to call it version.inc, but it can be whatever you want. I have attached the file I have defined but it is very simple.[post edit - the forum doesn't allow me to post a *.inc file so I've replaced it with an image]
Basically it is defining a flag for the compiler - In this example I am setting a flag "OPENTEMPLOT", you can switch to TEMPLOTMEC or TEMPLOT2 by uncommenting the relevant line.
What you then do is include this definition in any unit/form that works differently for the different versions. You do this by using the INCLUDE statement in the unit file - this example is in the control_room.pas and what it does is just include the text from the file defined - in this case version.inc.
What this means is that when the source code compiles you can define which bit of code is included in the compilation.
In the example below the original code is shown in blue. It depends on knowing the exact name for the application title, if it is exactly 'TemplotMEC' then you will get a yellow background, anything else would be blue. All of this code is included in the compilation.
Now we have defined compiler directives or flag this is where the "{$IFDEF" format takes over in the code. This sets the bits of code to include in the build. Because in version.inc I have selected OPENTEMPLOT you can see that section of code is black and enabled. The TEMPLOTMEC section because it hasn't been defined is shown in grey and disabled.
Hence my suggestion - it doesn't matter if you change the application title it will build the version required from the version.inc file. If we can agree on the definitions in that file then when people update the source code if they use these directives we can have one file that covers all three versions.
Note that in addition to the directive $IFDEF OPENTEMPLOT there is a negative version, $IFNDEF OPENTEMPLOT option says that if OPENTEMPLOT is not defined then include this bit of code.
If anyone is feeling really adventurous then you can include your own flag in the inc file e.g. "TemplotCherry" and then when writing code you can add in your own personalisations. Then in the include file by switching the $DEFINE option it is easy to switch between the standard OpenTemplot/TemplotMEC version and their own version.
Apologies if I'm getting too techy but I do think this would make it easier to maintain common code between the different projects.
If anyone has any queries about this then please raise them in this thread and I will do my best to answer them. Otherwise I apologise for introducing a lot of confusing computer speak to the forum.
Regards
Adrian
__________
message ref: 25086