Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"Out of string space"
#2
Well one thing is this: make sure for each module that you ONLY include .bi files that contain subs/functions used by that module.

imagine this is your program, broken up into subs:

Code:
MAIN (Module)
    Program.Run (Sub)
    Program.Init (Sub)
    Program.End (Sub)
GRAPHICS (Module)
    Show.Line (Sub)
    Show.Circle (Sub)
SOUND (Module)
    Play.Note (Sub)
    Play.Song (Sub)

let's say that you have a LIB with two functions: One that Clears the screen (yeah, yeah I know.. CLS.. just pretend!) and one that prints text to the screen. So maybe the .BI looks like this:

Code:
LIBRARY.BI
    DECLARE SUB ClearScreen ()
    DECLARE SUB PrintText (t$)

Okay, now if you call both of those functions in all three of your modules, you'd need to REM $INCLUDE 'LIBRARY.BI' three times, once at the start of each module.

If no routine in your SOUND module uses any of the variables, subs, or functions declared in LIBRARY.BI, you don't need to include it in that module.

Furthermore, let's say that the situation looks like this:

Code:
MAIN module needs ClearScreen AND PrintText.
GRAPHICS module needs just ClearScreen.
SOUND module needs just PrintText.

It seems like you'd need to include the whole library in all three modules. However, you can get around this by making a sub in ONE module that calls the library sub/function, and then just include the lib in THAT module. Your program would then look like this:

Code:
MAIN (Module)
    ClrScrn (Sub)
    PrntTxt (Sub)
    Program.Run (Sub)
    Program.Init (Sub)
    Program.End (Sub)
GRAPHICS (Module)
    Show.Line (Sub)
    Show.Circle (Sub)
SOUND (Module)
    Play.Note (Sub)
    Play.Song (Sub)

see? You only INCLUDE the library in the first module, not in the other two. the two new subs you make in the first module simply call the subs ClearScreen and PrintText (from the .LIB), passing along whatever arguments you supply:

Code:
SUB ClrScrn ()
    CALL ClearScreen ()
END SUB

SUB PrntTxt (t$)
    CALL PrintText(t$)
END SUB

You can now call these NEW subs from any module, and because the LIB is included in the module that's got these new subs, it will pass along the information as if the LIB's sub was included in the calling module. (i.e. you could call ClrScrn from GRAPHICS module, and it would be just like calling ClearScreen from GRAPHICS module, only without having to $INCLUDE the LIB into the GRAPHICS module).

When you compile the program, every time it encounters the $INCLUDE metacommand, it's the same as having typed in the entire library into your code at that point. So the fewer times you $INCLUDE a lib, the less likely you are to encounter memory / string space errors.

I hope this helps!

*peace*

Meg.
Reply


Messages In This Thread
"Out of string space" - by Jark - 05-21-2003, 02:23 AM
re: modules / libs - by Meg - 05-21-2003, 04:03 AM
"Out of string space" - by Antoni Gual - 05-22-2003, 12:16 AM
Got it ! - by Jark - 05-22-2003, 04:24 AM
"Out of string space" - by relsoft - 05-22-2003, 08:35 AM
"Out of string space" - by Antoni Gual - 05-22-2003, 05:52 PM
More information - by Jark - 05-22-2003, 06:21 PM
From what I can tell from QB's... - by Glenn - 05-22-2003, 10:31 PM
if you follow my above post, and try... - by Meg - 05-22-2003, 10:37 PM
"Out of string space" - by Antoni Gual - 05-23-2003, 12:29 AM
"Out of string space" - by Jark - 05-23-2003, 08:51 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)