Qbasicnews.com

Full Version: multiple files
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Original:
include sdl
include myfuncs.bi
include myfuncs.bas
Quote:Procedures shouldnt call other procedures anyways.

Main call all procs, proc never call proc.

:o

Do you know something about modular programming? Modules should call modules.

Quote:You only include it once. And with FB you don't really do modular coding the way you do in QB, you compile one file (most of the time) as you can go 2gb source anyways.

That's disorganization and bad practice. Why having to wait until everything compiles when you can compile just the changed module?

Quote:So having all functions in different files (only included once) will make it easier to find a specific function, just look in the inc folde,r and you'll se: Video_Pset.bi, for example.

If you include it once in your main code, you can even call it from other procedures if you want. FB is not C, C is weird. Big Grin FB is just crazy :lol:

C, and every other structural procedural language, has been designed by wise people to make things easier. Modular programming is a must and let's several people work for the same project, helps you isolating errors and stuff.

Executable code in header files is allowed in C as well, but it is a horrid programming practice, for reasons aforementioned.

But if you are happy coding in the wrong way... go for it. What you do is like advising to use line numbers and GOSUBs.

Quote:Where should I put '$include: "sdl/sdl.bi" and/or '$include: "myfunc.bi"

What I told you: you have to include the headers in those modules where you use the referenced functions. For example, in QB, when coding a game in DirectQB, directqb.bi has to be included in the modules that call DirectQB functions or subs. In short: in those modules where you need that the linker knows that there are SUBs or FUNCTIONs defined outside that module.
Pages: 1 2