Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Include files and functions

Author
Message
Radio Check
20
Years of Service
User Offline
Joined: 18th Aug 2004
Location:
Posted: 24th Aug 2004 22:04
My instinct and a habit from other programming ventures is to take everyting and put it in a function and keep my functions in various include files (sprites.inc, controller.inc, etc). That sometimes makes it hard to find things but usually clears up the main program loop.

Is this a common practice in DB? Is there any problem I need to know about? Does DB handle includes well? And why won't DBC load a *.inc file!

Thanks.

Making a cool sig is just too much pressure for me right now.
Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 24th Aug 2004 22:16
It is possible, but it isn't handled very well. Including files puts the compiler way off when reporting errors, and there's a number of other issues you might run into from time to time. About the *.inc, DBC doesnt support wildcards as far as I know, so you'll have to load them all manually unfortunately.

AMD Athlon XP2800+
GeForce FX5200 128MB
1024MB DDR 333MHz RAM
Radio Check
20
Years of Service
User Offline
Joined: 18th Aug 2004
Location:
Posted: 25th Aug 2004 00:20
Well, you certainly seem to be right. I was working along, and suddenly my program stopped working, sending me the most ignorant error messages. It started by telling me that my INK command didn't have the right parameters!

But then I read your reply, so I moved all my functions into the main program file and it started working!

I'm gonna hate that.

Making a cool sig is just too much pressure for me right now.
Radio Check
20
Years of Service
User Offline
Joined: 18th Aug 2004
Location:
Posted: 25th Aug 2004 13:36
Well, i really seem to be having a problem with functions in include files, they always seem to not be able to recognize perfectly reasonable variables. But then when I comment those problems out, it can't figure out the very next thing, whatever that is.

Is there a way of using functions in include files that works better? Because I really can concentrate better when my main loop is not cluttered up with code.

Thanks for any conversation on this issue.

Making a cool sig is just too much pressure for me right now.
StOrM3
21
Years of Service
User Offline
Joined: 24th Sep 2003
Location: Cyberspace
Posted: 27th Aug 2004 04:37 Edited at: 27th Aug 2004 04:38
this sounds like an issue I faced in blitz3d, you have to make sure your functions and types are declared and defined before you attempt to use them in other functions or in the main file.

I ran into this exact same issue. Takes some thinking to get things included in the right order..

Is this with Pro or Classic ? Because I have pro, and I wonder if debugger was fixed to include an #option explicit, which with the blitzcc fixed my issue, a prepprocessor.. maybe there is one for db or pro ?

[PKE] Pain Killa Entertainment(tm) [PKE]
Pain Brings Reality...
[PKE] Pain Killa Entertainment(tm) [PKE]
Radio Check
20
Years of Service
User Offline
Joined: 18th Aug 2004
Location:
Posted: 27th Aug 2004 05:46
Well... the first thing I usually do is include an "include" include...

A file that keeps track of all the other files.

But then I segregate my functions according to type, input, images, system. that gives me several includes and while it can be confusing, to me it is less confusing than scrolling up and down several hundred lines of code.

Making a cool sig is just too much pressure for me right now.
Radio Check
20
Years of Service
User Offline
Joined: 18th Aug 2004
Location:
Posted: 29th Aug 2004 11:28
OK, I found out what most of my problem was.

First) Apparently DBP automatically includes any fines added in the file management part of the "Project view", so explicitly #include'ing them is redundant.

Second) Any commands in include files should be inside a function and called in a function call. IOW, you can't just set a value, you have to run a function to set the value.

That seems to have cleared up my problems.

Making a cool sig is just too much pressure for me right now.

Login to post a reply

Server time is: 2024-11-27 08:34:34
Your offset time is: 2024-11-27 08:34:34