Page 1 of 1

Libraries

Posted: Mon Dec 24, 2007 12:13 pm
by Sinuvoid
How do I:

1.Create them

2. Use them

Ive looked at tutorials and they all seem to be saying different things :?

Posted: Mon Dec 24, 2007 1:45 pm
by Nodtveidt
That's not an easy question to answer.

You should know that generally, libraries contain only functions (SUB and FUNCTION in QB). If you're building a library with QB itself, you would simply have a project that contains a bunch of SUBs and FUNCTIONs that you don't want to have to copy over and over again. :) You would use the "Make Library" menu option in the QB editor. It'll create the library and quicklibrary automatically for you.

To make a library in assembly is different. The same basic concepts apply though; you're making a collection of functions. The difference is that you have to keep track of certain registers manually, and you have to know how to use LIB and LINK from the command line. Of course, you'll also have to know how to code in assembly language. :D

To use a library in the IDE, all you do is invoke the /l switch with the name of the library. Say you have library "foo", you do this:

qb /l foo

and the IDE will load with your library ready to use. Having the LIB alone isn't enough for the IDE; you also have to have the QLB version, which is what you need LINK for...I don't remember exactly how to do it (it's been at least 4 years since I did it last!) but information on how to do it isn't hard to find. I believe the syntax is something like...

link /qu bcom45.lib mylib.lib

or something like that...meh...I forget. :D

Also, most people who make libraries also tend to link in qb.lib. Since QB can only load one library at a time, lib.exe can assembly multiple library modules together to form a single .lib file, which you can then LINK to a QLB.

Posted: Mon Dec 24, 2007 1:49 pm
by burger2227
LOL I gotta say!

Posted: Mon Dec 24, 2007 2:46 pm
by Sinuvoid
UH, that doesnt help :? I meant't creating QB libraries and using them.

Heres my code if it helps...

Code: Select all

DECLARE SUB Popup (A AS INTEGER, B AS INTEGER, c AS INTEGER, d AS INTEGER, text AS STRING, x AS INTEGER, y AS INTEGER)
DECLARE SUB Textbox (A AS INTEGER, B AS INTEGER, c AS INTEGER, d AS INTEGER, text AS STRING, x AS INTEGER, y AS INTEGER)
DECLARE SUB Checkbox (A AS INTEGER, B AS INTEGER, c AS INTEGER, d AS INTEGER)
DECLARE SUB Backround (A AS INTEGER)
'**********************************************************************************************
'* This is Interface Library Created and Coded by Souylsin                                    *
'* Backround Command                                                                          *
'* x 1 TO 63 color of backround. 1 being black to 63 being white.                             *
'* Checkbox Command                                                                           *
'* x,x, top left corner  x, length x height                                                   *
'* Popup Command                                                                              *
'*  Stynax: a,b,c,d,"text",e,f                                                                *
'* a,b, top left corner  c, length d, height  "", text here e, x plane to put text f,         *
'* y plane to put text                                                                        *
'* Textbox Command                                                                            *
'* Same as Above                                                                              *
'**********************************************************************************************
'Testing area


'Backround Command
SUB Backround (A AS INTEGER)
PALETTE 1, A + (A * 256) + (A * 65536)
LINE (0, 0)-(320, 320), 1, BF
END SUB

'Checkbox Command
SUB Checkbox (A AS INTEGER, B AS INTEGER, c AS INTEGER, d AS INTEGER)
PALETTE 12, 0 + (0 * 256) + (0 * 65536)
LINE (A, B)-(c, d), 12, BF
PALETTE 11, 63 + (63 * 256) + (63 * 65536)
LINE (A, B)-(c, d), 11, B
PALETTE 10, 63 + (63 * 256) + (63 * 65536)
LINE (A + 10, B + 10)-(c - 10, d - 10), 10, B
END SUB

'Popup Command
SUB Popup (A AS INTEGER, B AS INTEGER, c AS INTEGER, d AS INTEGER, text AS STRING, x AS INTEGER, y AS INTEGER)
PALETTE 7, 63 + (63 * 256) + (63 * 65536)
LINE (A + 0, B + 0)-(c + 6, d + 5), 7, BF
PALETTE 9, 0 + (0 * 256) + (0 * 65536)
LINE (A, B)-(c, d), 9, BF
PALETTE 10, 63
LINE (A - 1, B - 1)-(c + 1, d + 1), 10, B
PALETTE 6, 63
LINE (A + 1, B + 1)-(c - 1, d - 1), 6, B
LOCATE x, y
PRINT text
END SUB

'Textbox Command
SUB Textbox (A AS INTEGER, B AS INTEGER, c AS INTEGER, d AS INTEGER, text AS STRING, x AS INTEGER, y AS INTEGER)
PALETTE 13, 0 + (0 * 256) + (0 * 65536)
LINE (A, B)-(c, d), 13, BF
PALETTE 11, 63 + (63 * 256) + (63 * 65536)
LINE (A, B)-(c, d), 11, B
END SUB


Posted: Mon Dec 24, 2007 2:58 pm
by Nodtveidt
You should be able to just "Make Library" on that code.

EDIT: In fact, I just tried it out and it built the library just fine. :D Now all you would have to do is create and '$INCLUDE a .bi for it that contains the DECLAREs, unless you want to put them at the top of the source code that's going to use the library. And again, don't forget the /l switch.

Posted: Mon Dec 24, 2007 3:00 pm
by Sinuvoid
Um, can you explain the last bit just a bit more? Im still kinda stumped :?
Thanks anyways :D

Posted: Mon Dec 24, 2007 3:03 pm
by Nodtveidt
You use its routines the same way you'd use any ordinary SUB or FUNCTION.

Posted: Mon Dec 24, 2007 3:06 pm
by Sinuvoid
Nodtveidt wrote:You should be able to just "Make Library" on that code.

Now all you would have to do is create and '$INCLUDE a .bi for it that contains the DECLAREs, unless you want to put them at the top of the source code that's going to use the library. And again, don't forget the /l switch.
Explain that more deeply please :)

Posted: Mon Dec 24, 2007 11:28 pm
by Nodtveidt
Okay, I'll try...

Alright, in the source for your library, the QB editor will, as with any other QB program, create the DECLAREs for each SUB or FUNCTION you make. What you do is copy these DECLARE lines to a new file with the .BI extension. Then, in the program you're going to make that uses the library, use something like

'$INCLUDE "mylib.bi"

at the top of your source code. That will include all of the declares for your library so the functions can be used.

Posted: Tue Dec 25, 2007 5:38 pm
by burger2227
To create a BI file, open Notepad and copy your original module Text Declares there. Then Save As. Click the dropdown box listed as Text and select ALL files and add .BI

You can do the same thing for BAS files from text.

Make sure to save your modules as Text Readable by other programs when saving them. Otherwise you will get a very ugly looking text file that you cannot read or copy. I imagine you already know that.

Still King here!

Ted

Posted: Tue Dec 25, 2007 7:10 pm
by Sinuvoid
K thanks Burger. btw, are you by any chance related to ted felix?

Same here

Posted: Fri Jan 04, 2008 4:12 pm
by Dav
Nodtveidt wrote: I don't remember exactly how to do it (it's been at least 4 years since I did it last!) but information on how to do it isn't hard to find. I believe the syntax is something like...

link /qu bcom45.lib mylib.lib

or something like that...meh...I forget. :D
Heh, I had forgotten how as well, so I looked at my old makeqlb.bat which contains:
LINK /Q %1.LIB, %1.QLB, NUL, BQLB45;

The old LIB knowledge slammed back into my head (I quess QB isn't hard to jump back into...).

So, to make a QLB from FUNPAK.LIB, we'd do a:
LINK /Q FUNPAK.LIB, FUNPAK.QLB, NUL, BQLB45;

The /Q switch says make a QLB. It can be placed at the end, just has to be before that semicolon. To make a map file, replace NUL
with its name, or leave the space blank and the name will be
FUNPAK.MAP.

- Dav

Posted: Mon Jan 07, 2008 7:34 pm
by Sinuvoid
Um still dont really get it on using the library :?