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 / is there an "include" as in C?

Author
Message
jayell leedham
18
Years of Service
User Offline
Joined: 24th Jan 2006
Location: North Yorkshire
Posted: 15th Mar 2008 00:09
As programmes get bigger there is a real need to "hive off" some code to simplify development, and call it up before compiling.
"C" uses an include command. As a real Newbie, I may have missed such a command in DBPro - have I?
Destrugter 1
17
Years of Service
User Offline
Joined: 26th Oct 2006
Location:
Posted: 15th Mar 2008 00:27
Yes, its #INCLUDE DBA Filename

do you love video games a lot ¿¿¿ then comeon down too game zone252 @ http://www.freewebs.com/gamezone252/
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 15th Mar 2008 02:01
You can also include extra files via the IDE (either the official one or any of the others available).

For the official IDE, make sure you are in project mode (View->Display Mode->Use Project View Mode), then click on the Files button on the lower right of the display.

Twinsen
18
Years of Service
User Offline
Joined: 20th Jun 2006
Location: Romania
Posted: 15th Mar 2008 07:25
I have a question ... if I have a huge code and I separate it into smaller .DBA files, how would I need to call them ( inclide them ) so that the order is preserved ?

Could you help me treat my injured Dino-Fly ?
jayell leedham
18
Years of Service
User Offline
Joined: 24th Jan 2006
Location: North Yorkshire
Posted: 15th Mar 2008 11:50
Many thanks.
Twinsen
18
Years of Service
User Offline
Joined: 20th Jun 2006
Location: Romania
Posted: 15th Mar 2008 19:16
hmm so you say they are appended to the end .... but are they in the order that I've added them ??? and if I label them, will I label the sources themselves or after I've included them ?

Could you help me treat my injured Dino-Fly ?
jayell leedham
18
Years of Service
User Offline
Joined: 24th Jan 2006
Location: North Yorkshire
Posted: 15th Mar 2008 23:24
I'm confused!!!
Sometimes I can put #include "sub.dba" at the beginning of the main dba file, where sub.dba is a separate dba file and consists solely of subroutines, and it all works fine. sometimes not! What is the rule? - the dba help system is not very forthcoming...
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 15th Mar 2008 23:26
It doesn't really matter; if you want something from file 2 or file 19, it will still have to be in a function or a subroutine.
Only the first source file can contain code that will be run without calling other parts (and that's what it's supposed to do - you make the first source file handle calls and returns to / from the other ones)

"I kören hörs de brummande busarna Björnligan och Gondolen"
Twinsen
18
Years of Service
User Offline
Joined: 20th Jun 2006
Location: Romania
Posted: 15th Mar 2008 23:35
so basically what u'r trying to say is that all .DBAs which are loaded separately (meaning it's not the main .DBA) act as subroutines which are executed in the order that they are called and not loaded .... right ???

Could you help me treat my injured Dino-Fly ?
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 16th Mar 2008 11:00 Edited at: 16th Mar 2008 11:11
Quote: "and consists solely of subroutines, and it all works fine. sometimes not! What is the rule?"


#Included files are supposed to contain only functions - not procedures/subroutines. That's not to say that having procedures in them doesn't work - I've just never tried because when I was learning to use DB the help files only said functions.

When you compile your program, the editor creates a temporary text file from your main DBA file then takes all of the #Include files and tags them on the end. This file then gets passed to the compiler.

So, the resulting exe is exactly the same as if you had created one big dba file in the first place and as such, calls to any of the functions in the #Include files from the main DBA file will work just fine.

The only things to watch out for are that you don't use the same function name in more than one #Include file and global Types are declared in the main program.

TDK_Man

jayell leedham
18
Years of Service
User Offline
Joined: 24th Jan 2006
Location: North Yorkshire
Posted: 16th Mar 2008 21:58
Thank you TDK, Windowskiller and Twinsen.

Because #include is not purely an "insert text" operation (as webpage php coding includes are), and is inserted at the end of the main file at pre-compilation time, it would seem that the code included must only consist of stand-alone functions and/or subroutines.

I don't understand Windowskiller's statement "If you want to execute included code first, give it a label and use GOSUB/RETURN", as I understand that functions and subroutines can be put anywhere except inside main coding; they will only be actioned if called upon.

To Twinsen - the order of the #includes therefore does not matter.
jayell leedham

Login to post a reply

Server time is: 2024-09-27 12:23:59
Your offset time is: 2024-09-27 12:23:59