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.

DarkBASIC Professional Discussion / User types and #Include

Author
Message
Dom
22
Years of Service
User Offline
Joined: 31st May 2004
Location:
Posted: 27th Jun 2005 05:25
Can I create Lots Of User Defined Types(UDTs) in one file then include that file in my main source code and access the types in my main code?


Thanks to Animeblood for the Logo!
Lost in Thought
22
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 27th Jun 2005 05:33
If you put them in a gosub, make them global, and call the gosub at the very top of your main program you can.

Jess T
Retired Moderator
22
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 27th Jun 2005 16:22
For an explanation as to why you have to do that, read the note on the #Include command at dbHelp;

http://jessticular.dbspot.com/index.php?nav=dbhelp&command=156

Jess.

Team EOD :: All-Round Nice Guy
Want Better dbHelp Files?
Dom
22
Years of Service
User Offline
Joined: 31st May 2004
Location:
Posted: 28th Jun 2005 01:10
Quote: " Which would print "Hello World" then wait for a key press.
This is handy to know, as if you put any commands in the file outside of a function or sub-routine, and you include it, then they will never get executed in a normal program, and would be completely ignored."
I really cannot make sense of this. At one point you say that the commands get appened to the end of the file then above you say they got completely ignored?


Thanks to Animeblood for the Logo!
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 28th Jun 2005 01:52 Edited at: 28th Jun 2005 01:52
it all gets tagged onto the end.. Functions get ignored as they dont run unless you explicity tell them too..

EG:

File1.dba
#include "File2.dba"
print "hello"

File2.dba
print myName("Nick")
wait key

function myname(strName$)
test$ = "My name is " + strName$
endfunction test$



Something like that SHOULD print:
Hello
My name is Nick

My Website:
Dom
22
Years of Service
User Offline
Joined: 31st May 2004
Location:
Posted: 28th Jun 2005 04:05
So I could create a function that initialise all of my Types in on file the use the function i another...that might just work!


Thanks to Animeblood for the Logo!
Lost in Thought
22
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 28th Jun 2005 04:41
You have to use a gosub instead of a function.

the_winch
23
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 28th Jun 2005 04:48
Most people use the ide to add include files instead of the #INCLUDE command.

Makes editing the files easier because you just select the include you want to edit from a combo box. Also since the ide is responsable for stiching the files together instead of the compiler it is more likley to report the correct line an error is on if it is not in the main source file.

Latest releases dll_tool v0.8 27 june | patch tool v0.6 22 June | exe_shrink v0.5 15 May
Eddie B
21
Years of Service
User Offline
Joined: 10th Apr 2005
Location:
Posted: 28th Jun 2005 04:49 Edited at: 28th Jun 2005 04:53
When you include , It adds it to the END of the file EG:

Main.dba:


other.dba:


Wouldnt work becuase it doesnt know what test is ( In the text bit ) becuase its at the end of the program PAST the text bit.. But if you where to do this:

Main.dba:


other.dba:


It should work becuase it loads all of the code. Then Put it in order ( Code is unchecked BTW ) ....

Hope I helped . - Eddie

(Edit: All done , There ya go )

!HI! : where can get the user32 dll from and how do i use it?
Raven
21
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 28th Jun 2005 05:53
true, but I don't see why the #include command doesn't insert the code where it is included rather than at the end in the order you include.

Order goes

Main -> DBPRO Include -> #Include

.. Functions it doesn't matter where they are same with constants as both are accessed by addres; but other things aren't.



If we take that an split it up like:

Type.dba


Program.dba


End.dba


So to put it back together would be like just altering the main.
Main.dba


If you were using Blitz3D, or PureBASIC then that WOULD work exactly like that. Just DB/P that doesn't which is annoying.

Keaz
22
Years of Service
User Offline
Joined: 22nd Sep 2003
Location: Somewhere in south Texas
Posted: 28th Jun 2005 07:21 Edited at: 28th Jun 2005 07:22
I've started always using gosub, unless I'm getting some sort of data returned. I got tired of having to Globalize my variables. It saved me some coding and a few asprin. But yeah when declaring variable types use a gosub because their global. I don't even bother with #include. I just add the files to my project.

Breaking Stuff=Fun!,Bug Testing<>Fun!, Bug Testing=Breaking Stuff, so...
Bug Testing=Fun! Hmmmm....
DOES NOT COMPUTE! SYSTEM MALFUNTION!
Dom
22
Years of Service
User Offline
Joined: 31st May 2004
Location:
Posted: 28th Jun 2005 16:10
Thak you all for your kind help!
I'm going to try all of the methods here and see which one works the best for me
Thanks again!


Thanks to Animeblood for the Logo!

Login to post a reply

Server time is: 2026-06-25 23:40:24
Your offset time is: 2026-06-25 23:40:24