Add file to project versus XInclude in the IDE

Just starting out? Need help? Post your questions and find answers here.
eck49
Enthusiast
Enthusiast
Posts: 153
Joined: Sat Nov 14, 2020 10:08 pm
Location: England

Add file to project versus XInclude in the IDE

Post by eck49 »

What is the fundamental difference between adding an existing file to a project and just including it with an XInclude?

Either way, a file can be reused in multiple projects.
It makes no difference to an Executable.
Searching (eg for a variable name) is within file anyway, so no difference there.

So I think there must be a concept I am missing.

Maybe (as a newcomer to PB) it is the way I am starting to arrange my projects?
Ubuntu 22.04 64-bit
Purebasic 6.00 (as of 5 Sep 2022)
(native tongue: English)
User avatar
spikey
Enthusiast
Enthusiast
Posts: 592
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: Add file to project versus XInclude in the IDE

Post by spikey »

eck49 wrote:What is the fundamental difference between adding an existing file to a project and just including it with an XInclude?
It changes the behaviour of the IDE, although you may have to alter your IDE preferences to see this fully in action.

When you use a project file you can tell the IDE to scan selected files, or all files, in the project for autocomplete information.
The files will be scanned regardless of whether or not they are open in the IDE. Without a project only the current file or open files will be scanned. This means you can still benefit from autocomplete without having to have dozens of tabs open in the IDE. The larger the project, the more important this becomes.

A project allows you to define multiple targets for compilation. This could be useful if your project produces more than one separate executable sharing some source files, produces both 32 and 64-bit versions, or if you want to target more than one version of the compiler, for example.

But yes, you are correct, you will still have to use (X)Include at some stage even if you are using a project file.
eck49 wrote:Searching (eg for a variable name) is within file anyway, so no difference there.
Have you seen the 'Find in files' option on the Edit menu?
eck49
Enthusiast
Enthusiast
Posts: 153
Joined: Sat Nov 14, 2020 10:08 pm
Location: England

Re: Add file to project versus XInclude in the IDE

Post by eck49 »

@Spikey, thank you for your response.

Ah, autocomplete.

So far, I have needed to have every file open so I can search for how I did something just a few days ago - or whether the already-invented wheel I am wanting is lurking in code I have downloaded from the forum! But once I am more confident, I can see how autocompleting from files which are not open could be very powerful.
A project allows you to define multiple targets for compilation
I don't think this will be useful to me, but I can see its potential for the wider clientele.

Edit: no I had not noticed Find in Files... until now.
Ubuntu 22.04 64-bit
Purebasic 6.00 (as of 5 Sep 2022)
(native tongue: English)
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: Add file to project versus XInclude in the IDE

Post by kenmo »

Off the top of my head... adding files to project:
- scans them for Auto-complete
- when you Build/Run on a project file, the IDE knows to build the project (not the individual include file)
- loading a project will warn you if a linked file has been changed externally
- files listed in the "Project" tab - double-click a file to open it
... maybe more?


But really, with PureBasic, you don't need to configure a "project" unless your project gets big enough, or you want to build different variants.

It's one of the things I love about PB unlike some languages... project not required... just start typing and hit F5 to go!
Post Reply