Working with projects

Everything else that doesn't fall into one of the other PB categories.
AMpos
Enthusiast
Enthusiast
Posts: 128
Joined: Fri Jun 05, 2020 12:47 am

Working with projects

Post by AMpos »

Hi!

Im new with PureBasic, although a long, long, time programming with various Basics.

There is a thing that is driving me crazy, but I guess it has to be a really silly thing.

I have created a Proyect, with 2 files, MAIN, and SECOND

Both files are in the proyect (or so I think), but I can not call PROCEDURES created in SECOND from MAIN program.

If I type in MAIN, autocomplete finds the procedure created in SECOND, but after I click RUN, I got the error "MyProc() is not a function,..."

What am I doing wrong?
User avatar
StarBootics
Addict
Addict
Posts: 984
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: Working with projects

Post by StarBootics »

Hello,

Did you put in your MAIN file IncludeFile "SECOND" file ?

Best regards
StarBootics
The Stone Age did not end due to a shortage of stones !
AMpos
Enthusiast
Enthusiast
Posts: 128
Joined: Fri Jun 05, 2020 12:47 am

Re: Working with projects

Post by AMpos »

Yes, it did the work.

Thank you.

(I though it would be automatically included)
Marc56us
Addict
Addict
Posts: 1479
Joined: Sat Feb 08, 2014 3:26 pm

Re: Working with projects

Post by Marc56us »

AMpos wrote:(I though it would be automatically included)
The files to be included in a project are not automatically included because it can be done conditionally (i.e. depending on the type of CPU) since a project can compile several versions at the same time.

PS. Also prefer XInclude to Include.

Code: Select all

; Main.pb

CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
    XIncludeFile "Second_x64.pbi"
CompilerElse
    XIncludeFile "Second_x86.pbi"
CompilerEndIf
We most often use .pbi as an extension to differentiate Include files from others, but it doesn't matter.

:wink:
AMpos
Enthusiast
Enthusiast
Posts: 128
Joined: Fri Jun 05, 2020 12:47 am

Re: Working with projects

Post by AMpos »

I have this

/Purebasic
//MyProyect
...main.pb
...tobeincluded.pb
//CommonFunctions
...Zones.pb

I can add "zones.pb" to my proyect, but how do I include it?

How do I include it? Will

INCLUDE "zones.pb"

works, as it is added to the proyect, or have I to include with full/relative path?
Marc56us
Addict
Addict
Posts: 1479
Joined: Sat Feb 08, 2014 3:26 pm

Re: Working with projects

Post by Marc56us »

The files you add in the Project Manager are just data that allows the IDE to know for example which scanner files to use for the variable list.
It's just the main project file must contain XInclude lines
It also allows you to launch the compilation of the project even if you are not editing the main file.
If the files to be included are in different directories from the main file, then you must specify the path (absolute or relative)

i.e Main.pb

Code: Select all

XInclude "Second.pb"
XInclude "..\tobeincluded.pb"
XInclude "C:\Zones.pb"
; The main code
PS Avoid full path as this cause problem if you move project in future.

:wink:
AMpos
Enthusiast
Enthusiast
Posts: 128
Joined: Fri Jun 05, 2020 12:47 am

Re: Working with projects

Post by AMpos »

Damm... my purebasic programs are in a google drive folder, so they are updated between my computers... so, the full path is not the same always...
Marc56us
Addict
Addict
Posts: 1479
Joined: Sat Feb 08, 2014 3:26 pm

Re: Working with projects

Post by Marc56us »

AMpos wrote:Damm... my purebasic programs are in a google drive folder, so they are updated between my computers... so, the full path is not the same always...
I don't use Google Drive, but it should be possible to map a resource such as a network drive or by UNC
Other solution: synchronize local and remote (RoboCopy, Syncbackup) or even create a local GIT repository on Google Drive ?

:wink:
AMpos
Enthusiast
Enthusiast
Posts: 128
Joined: Fri Jun 05, 2020 12:47 am

Re: Working with projects

Post by AMpos »

Google Drive has itself a synchronice program :) but the path is "C:\Users\oneuser\Google Drive" and in another computer, "C:\Users\otheruser\Google Drive"

I will try using

INCLUDE "../CommonFuntions/zones.pb"

perhaps it works...
Marc56us
Addict
Addict
Posts: 1479
Joined: Sat Feb 08, 2014 3:26 pm

Re: Working with projects

Post by Marc56us »

AMpos wrote:Google Drive has itself a synchronice program :) but the path is "C:\Users\oneuser\Google Drive" and in another computer, "C:\Users\otheruser\Google Drive"
No problem. You can map a drive letter to a local directory on each PC ("Net use" works on local using \\localhost as "server" name)

Code: Select all

NET USE Z: "\\localhost\Users\oneuser\Google Drive"
So you can then use Z: wherever you where

:wink:
Post Reply