Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Lib trouble
#1
Ok, I've just made a text based grahics library. My first Lib ever.

After Compiling, I was given Zext.qlb and Zext.lib

One question: How do I get the BI file? I manually made one by typing out the titles of all the subs in the source code, then saving it to get all the DECLAREs. But is there an automatic way to get the BI file made?

But the main problem: I compiled the library, loaded it in QB, and included the BI file I made. Then I proceeded to test it out. It produced: Nothing. Not even any errors. Just nothing on the screen. Of course, it works fine just using the original source SUBs, but not in library form.

I am using SCREEN 0, WIDTH 80, 50. The subs appear to be setting the colours, alright, as I can see the colours in the
"Press Any Key to Continue"
bitty. But nothing actually appears.

To get the symbols to type, I am using an array storing 4 different characters, assigned in the BI file. The array is SHARED. Does this need to be declared somewhere else in order for the Lib subs to read from the array? As I imagine this is the problem.
Reply
#2
hmmm that's weird. :???: If the declarations weren't there, there would be an error message(QB saying it can't find that certain function in memory). Are you even calling the functions that are included in the library? Maybe an example of the code you are using would help.
Reply
#3
Yeah, post the code.

I have two guesses about what could be happening, but I have to see your library.

And no, BI files can't be generated automaticly. What I do is just trim the declarations section in the BAS file and copy it to a BI file.

About your SHARED array: if it only has to be accesible from within the library module (i.e., it is hiden outside of it, it is just a internal array to the lib), you should define it on the main section of the compiled library. If no, it should be in the BI file with a COMMON statement, but I don't like it at all 'cause it goes haywire Tongue
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#4
dark you shouldnt go around making libraries without enough knowledge about what is API, encapsulation etc...

Learn that first and then try making a lib =). Anyway post your code and we will help you out.
Reply
#5
Quote:Are you even calling the functions that are included in the library? Maybe an example of the code you are using would help.

Yes. The functions are defintely being called, as the colours are being set. (The colours are set from within the subs)

Quote:dark you shouldnt go around making libraries without enough knowledge about what is API, encapsulation etc...

Er... Sorry!? The main reason I made it was just because I wanted to try to make a library, as I have never attempted one before.

Quote:About your SHARED array: if it only has to be accesible from within the library module (i.e., it is hiden outside of it, it is just a internal array to the lib), you should define it on the main section of the compiled library. If no, it should be in the BI file with a COMMON statement, but I don't like it at all 'cause it goes haywire

Yes, I am sure that the array is the problem. My previous post was written a little quickly, so I'll try to explain it better:

The array hold 4 chars in 4 subscripts: 0-3. The characters are then printed in the sub like this:

PRINT zextsats$(zextsat); Where "zextsat" is a number from 0 to 3.

The array only has to be accessible in the subs and functions of the Lib, nowhere else. I declared the array in the BI file, using DIM SHARED but not using COMMON. Do I have to use COMMON? If so, wont it give me a "Duplicate definition" error if I COMMON it and DIM it?
Reply
#6
Dude dont get me wrong. I wasnt discouraging you from making one. I was only trying to tell you that you should first understand the principles of libraries and then implement one.

The idea of sharing variables isnt good. You should ideally provide a function: get_zext_sats$(var%) which will return the appropriate string.

To use common shared:

Code:
Mod1:

COMMON SHARED a%
COMMON SHARED arr%()
DIM SHARED arr%(1 to 10)

a% = 10

for i% = 1 to 10
   arr%(i%) = i% * 10
next

Mod2:
COMMON SHARED a%
COMMON SHARED arr_bleh%()
DIM SHARED arr_bleh%(1 to 10)

print a%

for i% = 1 to 10
   print arr_bleh%(i%)
next


Notice that i have used arr_bleh instead of arr in the second mod? It doesnt matter what you name the variable as long as the order is correct =).
Reply
#7
Quote:The idea of sharing variables isnt good. You should ideally provide a function: get_zext_sats$(var%) which will return the appropriate string.

Thats actually a rather good idea!


Quote:It doesnt matter what you name the variable as long as the order is correct =).

Ok, So you can COMMON then DIM? Ok, I though you got an error when doing that, but I think I did it in the wrong order yesterday.

But also, would using an array not be faster than a whole function to get the zextsats$ string?
Reply
#8
If the array is gonna used only inside the lib (internal array) just DIM it SHARED in the main section of your library and remove it from the BI file.

What TBBQ says about having a function is definitely a good idea. It saves memory. It is slower, of course, but you won't tell.

That's one of the things I try to explain in my tut: http://faq.qbasicnews.com/?blast=PushingTheLimitsOfQb

Btw, who is the folk who reorganizes the FAQ everyday? I am having headaches to find my stuff lately :-?
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#9
Ok. I just realised a way to reorganise my Subs so that they wont be as slow, and the function for zextsats$ wont make it slower. Thanks guys.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)