Compiler: Do not attempt to compile pbi file
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Compiler: Do not attempt to compile pbi file
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.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Compiler: Do not attempt to compile pbi file
You can set the: Main source file
in the Compiler Options!
in the Compiler Options!
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Re: Compiler: Do not attempt to compile pbi file
Hi IdeasVacuum,
Perhaps defining a constant in the main program that the pbi depends upon to compile?
This prevents the pbi file from being compiled by itself.
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
Last edited by ElementE on Tue Oct 27, 2015 9:03 pm, edited 1 time in total.
Think Unicode!
Re: Compiler: Do not attempt to compile pbi file
simpler:
should prevent that you could compile the pbi.
Code: Select all
compilerif #pb_compiler_ismainfile
compilererror "this is a PBI!"
compilerendif
Re: Compiler: Do not attempt to compile pbi file
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.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
-
- Enthusiast
- Posts: 443
- Joined: Sun Apr 06, 2008 12:54 pm
- Location: Brisbane, Qld, Australia
- Contact:
Re: Compiler: Do not attempt to compile pbi file
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.
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Compiler: Do not attempt to compile pbi file
Thanks for all the suggestions!
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.
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.Main source file in the Compiler Options!
Again, for this type of use, PB Projects are just too onerous to maintain.Have you set up a PB Project?
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.Perhaps defining a constant in the main program that the pbi depends upon to compile?
This works. Yet even at the top of a large file, the Compiler takes too long to halt and pop up the message.compilerif #pb_compiler_ismainfile
compilererror "This is a pbi!"
compilerendif
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.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.