Procedures and Include Files

Just starting out? Need help? Post your questions and find answers here.
lesserpanda
User
User
Posts: 65
Joined: Tue Feb 11, 2020 7:50 am

Procedures and Include Files

Post by lesserpanda »

Hi, I have split certain procedures into different files.
XInclude them back accordingly.
I have hit an issue where I'm cross-referencing procedures.
E.g. Procedure A (which is in File A.pbi), and Procedure B (which is in File B.pbi)

Code: Select all

Procedure A()
  B()
EndProcedure

Code: Select all

Procedure B()
  A()
EndProcedure
So how do I cross reference it without hitting issues with include files and the order it's included in?
User avatar
jacdelad
Addict
Addict
Posts: 1418
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: Procedures and Include Files

Post by jacdelad »

Code: Select all

Declare
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
User avatar
skywalk
Addict
Addict
Posts: 3960
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Procedures and Include Files

Post by skywalk »

Sure, there is Declare, but you also see a pattern with your code buckets.
Done properly, the conflicts will be few.
If you have more than a handful I would rearrange your buckets.
I think I have 5 Declares in ~100k lines.

I do have a few repeating #CONSTANTS at the top of some pbi's.
As long as their values are unchanged, PB allows it.

Keep coding!
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
jacdelad
Addict
Addict
Posts: 1418
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: Procedures and Include Files

Post by jacdelad »

I used exactly 3 Declares for 100.000 lines of code. Yes, usually it should be mostly avoidable.
But to solve the given problem you need Declares in the main file before XIncluding the pbi's. Or not?
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
lesserpanda
User
User
Posts: 65
Joined: Tue Feb 11, 2020 7:50 am

Re: Procedures and Include Files

Post by lesserpanda »

Thanks guys, I ended up re-shuffling the xincludes and it turned out ok for now.
Bitblazer
Enthusiast
Enthusiast
Posts: 730
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: Procedures and Include Files

Post by Bitblazer »

Don't forget about Modules.
webpage - discord chat links -> purebasic GPT4All
User avatar
skywalk
Addict
Addict
Posts: 3960
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Procedures and Include Files

Post by skywalk »

Modules definitely complicate syntax.
Great for sharing code if existing, but I mostly use xxx_lib.pbi, yyy_lib.pbi.
Easy peasy and I can automate my amalgamated code base.
Modules add cruft and weird rules for globals, macros, structures, and prototypes.
Once you learn basic PB syntax, you have to relearn for Modules.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Post Reply