Qbasicnews.com
May 26, 2020, 06:20:56 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Totally modular, dude \m/ :P  (Read 3229 times)
Anonymous
Guest
« on: January 12, 2004, 04:20:13 AM »

hey now i know to use modules. My next question. How the freak do I pass control to one? thanx.
Logged
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #1 on: January 12, 2004, 05:05:47 AM »

You can't pass control to another module. You just call its subs and functions.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Nexinarus
Wandering Guru
***
Posts: 301



WWW
« Reply #2 on: January 12, 2004, 08:12:53 AM »

pretend a module is a library, but you can share variables aswell.
Logged
Zack
*/-\*
*****
Posts: 3974



WWW
« Reply #3 on: January 12, 2004, 11:10:24 AM »

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?
Logged

f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #4 on: January 12, 2004, 11:41:46 AM »

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 Smiley
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
oracle
*/-\*
*****
Posts: 3652



WWW
« Reply #5 on: January 12, 2004, 07:28:47 PM »

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.
Logged

Zack
*/-\*
*****
Posts: 3974



WWW
« Reply #6 on: January 12, 2004, 08:10:05 PM »

Cool, I never saw that before. Cheesy
Logged

f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Anonymous
Guest
« Reply #7 on: January 14, 2004, 03:11:35 PM »

hey thanx nath Smiley 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
Logged
adosorken
*/-\*
*****
Posts: 3655



WWW
« Reply #8 on: January 14, 2004, 05:24:18 PM »

cha0s. Smiley

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.
Logged

I'd knock on wood, but my desk is particle board.
Jark
Ancient Guru
****
Posts: 566



WWW
« Reply #9 on: January 14, 2004, 10:12:52 PM »

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...).
Logged

hink Global, Make Symp' All !
Jark
Ancient Guru
****
Posts: 566



WWW
« Reply #10 on: January 15, 2004, 06:39:50 AM »

I have just finished a sort of tuto that deals with libs and modular programming. I wrote something very simple, almost debutant's oriented, but it addresses a complete study case.

I would appreciate your opinion about it, in order to improve that  :wink:

http://mandelbrot.dazibao.free.fr/Qbprog/Qbprog.htm
Logged

hink Global, Make Symp' All !
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #11 on: January 15, 2004, 12:41:55 PM »

I think the tute is great. Do you want access to the FAQ? This should be added Smiley

I want to note that I disregard using shared stuff not 'cause it is bad, but 'cause it is tricky. It is easier to overcome memory and definition problems if you get rid of them, as they are completely unneeded if you don't mind typing a little bit more Wink Of course, some SHARED stuff is mandatory, but only at module level. You don't really need inter-module shareds if you know how to schedule your programming and plan it properly.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!