Getting Familiar With Libraries

You can use libraries as you use Subs and Functions.
Library is really easy to create and you can add there routines and codes that are used in your programs often, just as you use Subs and Functions.

Well, why use own library instead of Subs or Functions?

In QBasic is a limit that all knows. Its called 64K barrier. But using your own libraryes, you can avoid it. EXEs are created in QBasic with two program co-operation. At first it will be compiled as a OBJ file with BC.EXE and after that it will be linked to EXE with LINK.EXE. Libraryes are added on your program on linking part, after BC.EXE compiles your program to OBJ. 64K limit is on BC.EXE program not on LINK.EXE anymore (when libraryes are added also) so basicly you can do this way programs what sizes can be more than 64K. In matter affact, there are no limits then.

Here is a simple example how to create and use your own library. Start QB.EXE with no parameters.

Sub PrintMe
    Print " I made it!!!"
End Sub

Now you gotta make it as a library. Just go on Run and choose MAKE LIBRARY. Ok, so now you got a library there. Now quit your QBasic and re-start it with parameter QB.EXE /L YourLibrary.QLB Now, type these line and you see how it works.

Declare Sub PrintMe Alias "PrintMe" ()

Print "Now we move on library..."
Call PrintMe
Print "...and now we are back on main program."

Now, press F5 and see what happends ;)

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.