Page 1 of 1

Working with projects

Posted: Fri Jun 05, 2020 12:58 am
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?

Re: Working with projects

Posted: Fri Jun 05, 2020 1:18 am
by StarBootics
Hello,

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

Best regards
StarBootics

Re: Working with projects

Posted: Fri Jun 05, 2020 1:31 am
by AMpos
Yes, it did the work.

Thank you.

(I though it would be automatically included)

Re: Working with projects

Posted: Fri Jun 05, 2020 10:31 am
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:

Re: Working with projects

Posted: Fri Jun 05, 2020 10:55 am
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?

Re: Working with projects

Posted: Fri Jun 05, 2020 11:02 am
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:

Re: Working with projects

Posted: Fri Jun 05, 2020 11:09 am
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...

Re: Working with projects

Posted: Fri Jun 05, 2020 11:26 am
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:

Re: Working with projects

Posted: Fri Jun 05, 2020 11:43 am
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...

Re: Working with projects

Posted: Fri Jun 05, 2020 1:20 pm
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: