External Tools - Compilefile

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

External Tools - Compilefile

Post by Josh »

Before Compile/Run
The tool will be executed right before the compiler is called to compile a source code. Using the %COMPILEFILE token, you can get the code to be compiled and modify it. This makes it possible to write a small pre-processor for the source code.
Some years ago, I tested a long time with this function. This run well, if you use only a single file. Using include files, this function is definitely useless.

Is it possible, that the Pb compiler is using codefiles with a specific subfix, if the file with this subfix is available. For example, I have a project with tree files:
  • MainFile.pb
  • IncFile1.pb
  • IncFile2.pb
Now I'm starting the compiler and with my preprocessor I'm scanning the codefiles and see, that I want to make changes in Mainfile and IncFile2. So I'm creating the following files with my changes in the same directory where the original files are stored:
  • MainFile.pb.Compilefile
  • IncFile2.pb.Compilefile
When my preprocessor has finished and gives back the control to the compiler, the compiler is running like following:
  • The compiler finds MainFile.pb.Compilefile and use the code from this file.
  • If the compiler runs to XIncludeFile "IncFile1.pb" and there is no IncFile1.pb.Compilefile, the compiler is using IncFile1.pb
  • If the compiler runs to XIncludeFile "IncFile2.pb" and there is an IncFile2.pb.Compilefile, the compiler is using IncFile2.pb.Compilefile
And now, the major argument, where the current system completely fails. If the compiler is running to an error, the IDE has to show the error in the original code. So, when I make my changes in a way, that the line numbers are not changed, I have the perfect system.
sorry for my bad english
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: External Tools - Compilefile

Post by Little John »

Josh wrote:Using include files, this function is definitely useless.
I disagree. The preprocessor just hast to be written properly. My preprocessor LPP can handle include files.
Josh wrote:If the compiler is running to an error, the IDE has to show the error in the original code.
Yes, that would be really useful. I currently also don't know how to achieve that.

For a more detailed feature request in this regard see here.
Last edited by Little John on Sun Jul 07, 2013 9:02 am, edited 1 time in total.
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: External Tools - Compilefile

Post by Josh »

Little John wrote:Yes, that would be really useful. I currently also don't know how to achieve that.
That's the reason, why it's definitely useless. If you are working with a system where compiler errors are shown in a wrong file, you must be a masochist :mrgreen:
sorry for my bad english
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: External Tools - Compilefile

Post by Little John »

Josh wrote:
Little John wrote:Yes, that would be really useful. I currently also don't know how to achieve that.
That's the reason, why it's definitely useless.
"Useless" is a great exaggeration and not applicable. People are making use of this feature, and although it is not perfect, I for one am happy that it exists. So "useless" is definitely wrong.
Post Reply