Is this possible

General FreeBASIC programming questions.
Gablea
Posts: 1049
Joined: Apr 06, 2010 0:05
Location: Northampton, United Kingdom
Contact:

Is this possible

Postby Gablea » May 05, 2010 22:59

Hi,

is it posible to put say all the graphic sub function in one BI and call it from any where in my application?

Andy
agamemnus
Posts: 1842
Joined: Jun 02, 2005 4:48

Postby agamemnus » May 06, 2010 0:14

Yup, but you need to "include" it before you can use it -- "include" tells the compiler to copy a file's contents to the source code in the order you included it.

So, say your program structure is like this:

main.bas -> has #include once "gui.bi" on top, then #include once "dbfunctions.bas" below that. "Dbfunctions.bas" would have access to "gui.bi".
Gablea
Posts: 1049
Joined: Apr 06, 2010 0:05
Location: Northampton, United Kingdom
Contact:

Postby Gablea » May 06, 2010 0:19

Cool

so would my include file be like

#Include Once "FBGFX.BI"
#Include Once "vbcompat.bi"
#Include Once "Global.bi"
#Include Once "DataGlobal.bi"
#Include Once "DataMod.BI"
#Include Once "GUI.BAS"


and then in the GUI.bas do I need to delare all the subs?
agamemnus
Posts: 1842
Joined: Jun 02, 2005 4:48

Postby agamemnus » May 06, 2010 0:47

Yeah. You can also include within included files, but I prefer to include everything in the main file for clarity.
Gablea
Posts: 1049
Joined: Apr 06, 2010 0:05
Location: Northampton, United Kingdom
Contact:

Postby Gablea » May 06, 2010 14:16

great thanks :)

thank has made what I want to do a LOT easier :)
agamemnus
Posts: 1842
Joined: Jun 02, 2005 4:48

Postby agamemnus » May 06, 2010 14:45

Oh, I just realized you might have meant actually "DECLARE"ing the subs.

To clarify, you don't need to declare subs/functions. By declaring them, you can refer to them in code before you define them. It's again another compiler trick (I think) -- the compiler just goes ahead in the code, searches for the sub, and replaces the declaration with the sub.

It's perfectly fine not to declare subs/functions that are not part of UDTs (user-defined types).
Gablea
Posts: 1049
Joined: Apr 06, 2010 0:05
Location: Northampton, United Kingdom
Contact:

Postby Gablea » May 06, 2010 15:29

so would I need to declare

Declare Sub SaleScreen

inside the GUI.bas?


or woud it be on the .bas where I am calling it from
rolliebollocks
Posts: 2655
Joined: Aug 28, 2008 10:54
Location: new york

Postby rolliebollocks » May 06, 2010 15:30

You should put the declare in whichever file holds the subroutine... Not the call to the subroutine...

Return to “General”

Who is online

Users browsing this forum: Majestic-12 [Bot] and 25 guests