Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Totally modular, dude \m/ :P
#1
hey now i know to use modules. My next question. How the freak do I pass control to one? thanx.
Reply
#2
You can't pass control to another module. You just call its subs and functions.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#3
pretend a module is a library, but you can share variables aswell.
Reply
#4
So fill me in here. I gotta get into this fun...
You make SUBs and FUNCTIONs and whatever other declarations/variable assignments you want, and then '$INCLUDE them?
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#5
Read my tut about it: http://faq.qbasicnews.com/?blast=PushingTheLimitsOfQb

Basicly you have a main BAS file with a main section (outside subs) and SUBs and FUNCTIONs as well. The you add more BAS files that only contain DIM SHAREDs, COMMONs, TYPEs and more SUBs and FUNCTIONs. To make those SUBs and FUNCTIONs visible from another module (your main module, for example), you have whether to:

1.- Add the DECLAREs to the module you want to call extern SUBs of FUNCTIONs from.

2.- Stuff all the DECLAREs in a BI file and '$INCLUDE it in the module you want to call extern SUBs or FUNCTIONs from.

What I do is having a different BI file for each module I have, that way I '$INCLUDE just what I need. I think it is cleaner Smile
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#6
No code in any module other than the module you set as the main module will be executed, unless it is a SUB or FUNCTION and you have called it from the main module.

To change the main module, turn full menus on and look in the Run menu.
Reply
#7
Cool, I never saw that before. Big Grin
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#8
hey thanx nath Smile now alls i gotta do is remember where in the XMS i put all my data ;p

oh, btw i have another question!!

lets say i redimmed an array Tile(130) as integer

ok, now lets say i moved to another module, but i didnt share the array.

what happens if i point to it from the other module? cha0s? Wink
Reply
#9
cha0s. Smile

If your array isn't SHAREd across modules and isn't passed as an argument (oi!!!), it won't be available to a function in another module.
I'd knock on wood, but my desk is particle board.
Reply
#10
What I like in Nathan excellent tut is that it insists on the fact that shared variables are really tricky to control with the modular approach.

Based on my experience with the TC-Lib and TC-Ray, where I used a lot of shared and common shared stuff, I think I will come back to the "observers" and "modifiers" logics in the future versions.

I think sending and receiving parameters from module to module, through subs that don't do anything but transmitting these parameters, is an excellent solution (though it can also lead to saturating the stack if there are too many local variables...).
hink Global, Make Symp' All ! ®
[Image: Banner.gif]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)