Page 1 of 1

Compiler: Do not attempt to compile pbi file

Posted: Tue Oct 27, 2015 7:56 pm
by IdeasVacuum
I would like to have a Compiler Option whereby Compile/Run and Syntax Check only work if the current file is a .pb. Many a time I have accidently started compile/Run in a pbi file where compile will fail because the pbi is dependent on the master pb file - with large files, the failure takes too long to arise.

Re: Compiler: Do not attempt to compile pbi file

Posted: Tue Oct 27, 2015 8:20 pm
by ts-soft
You can set the: Main source file
in the Compiler Options!

Re: Compiler: Do not attempt to compile pbi file

Posted: Tue Oct 27, 2015 8:27 pm
by ElementE
Hi IdeasVacuum,
Perhaps defining a constant in the main program that the pbi depends upon to compile?

Code: Select all

; File: "Test.pb"
#Main_Defined = 1
IncludeFile "test.pbi"
Debug "main program"

Code: Select all

; File: "Test.pbi"
CompilerIf #Main_Defined
  Debug "Main Defined"
  Debug "All is OK" 
CompilerEndIf
This prevents the pbi file from being compiled by itself.

Re: Compiler: Do not attempt to compile pbi file

Posted: Tue Oct 27, 2015 8:49 pm
by GPI
simpler:

Code: Select all

compilerif #pb_compiler_ismainfile
compilererror "this is a PBI!"
compilerendif
should prevent that you could compile the pbi.

Re: Compiler: Do not attempt to compile pbi file

Posted: Tue Oct 27, 2015 8:50 pm
by skywalk
I design my pbi's to allow each to be tested independently of the main project. Of course, some pbi's require XIncludeFile's of others to function, but that is normal and mitigated with #CompilerIf's as ElementE shows.

Re: Compiler: Do not attempt to compile pbi file

Posted: Wed Oct 28, 2015 8:04 am
by ozzie
Have you set up a PB Project? If you do that, and add your .pb file and all the .pbi files to the project (under Project Options), and set the 'Input source file' as mentioned by ts-soft, then it doesn't matter which file has focus when you compile.

Re: Compiler: Do not attempt to compile pbi file

Posted: Thu Oct 29, 2015 2:10 am
by IdeasVacuum
Thanks for all the suggestions!
Main source file in the Compiler Options!
I often have more than one main source file in the IDE when I'm using them as on-the-fly-editied utilities to support other code or produce data for external apps such as a CAD program, so defining one Main in Compiler Options does not help.
Have you set up a PB Project?
Again, for this type of use, PB Projects are just too onerous to maintain.
Perhaps defining a constant in the main program that the pbi depends upon to compile?
There almost always is, and the Compiler takes a month of Sundays to decide that the .pbi won't compile because of that, as per my original post.
compilerif #pb_compiler_ismainfile
compilererror "This is a pbi!"
compilerendif
This works. Yet even at the top of a large file, the Compiler takes too long to halt and pop up the message.

At the end of the day, I feel that my request holds good - a simple check box in Compiler Options so that compile does not start if the file is a .pbi, just posts a message in the error log.