what are libraries?

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!
Post Reply
... or guest or ????

what are libraries?

Post by ... or guest or ???? »

what are libraries?
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

Libraries are groups of SUB routines to include into the code.... If you have a hundred SUBs that are used for costum commands like:

Code: Select all

SUB TYPE(TEXT01$, X01, Y01)
    FOR i = 1 TO LEN(TEXT01$)
        T! = TIMER
        PTRL$ += MID$(TEXT01$, i, 1)
        LOCATE Y01, X01: PRINT PTRL$;
        DO: LOOP UNTIL (TIMER - T!) >= .2
    NEXT
END SUB
You could make them into a lib.... So, insted of the code being like this:

Code: Select all

DECLARE SUB TYPE(TEXT01$, X01, Y01)

TYPE "Hello, world", 1, 1
SLEEP

SUB TYPE(TEXT01$, X01, Y01)
    FOR i = 1 TO LEN(TEXT01$)
        T! = TIMER
        PTRL$ += MID$(TEXT01$, i, 1)
        LOCATE Y01, X01: PRINT PTRL$;
        DO: LOOP UNTIL (TIMER - T!) >= .2
    NEXT
END SUB
It be like this:

Code: Select all

'$include: 'type.bi'

TYPE "Hello, world", 1, 1
SLEEP
Cuts down on lines of code, and makes things look nicer.. :wink: ..

Quick compare: Libraries in life are buildings with books of knowlegde we can go to and use;;; Libraries in code are the same, the code can go to these files and use the routines from them...
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
... or guest or ????

Post by ... or guest or ???? »

i don't get what you mean by routines
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

Dictionary.com wrote:Routine

Computer Science. A set of programming instructions designed to perform a specific limited task.
Take my above example,. insted of doing this every time I want a typing effect:

Code: Select all

TEXT01$ = "Hello, world": X01 = 1: Y01 = 1

FOR i = 1 TO LEN(TEXT01$)
    T! = TIMER
    PTRL$ += MID$(TEXT01$, i, 1)
    LOCATE Y01, X01: PRINT PTRL$;
    DO: LOOP UNTIL (TIMER - T!) >= .2
NEXT

TEXT01$ = "How are you?": X01 = 1: Y01 = 2

FOR i = 1 TO LEN(TEXT01$)
    T! = TIMER
    PTRL$ += MID$(TEXT01$, i, 1)
    LOCATE Y01, X01: PRINT PTRL$;
    DO: LOOP UNTIL (TIMER - T!) >= .2
NEXT
I can make it a SUB routine and CALL it ever time I need it insted of coding it:

Code: Select all

TYPE "Hello, world", 1, 1

TYPE "How are you?", 1, 2

SUB TYPE(TEXT01$, X01, Y01)
    FOR i = 1 TO LEN(TEXT01$)
        T! = TIMER
        PTRL$ += MID$(TEXT01$, i, 1)
        LOCATE Y01, X01: PRINT PTRL$;
        DO: LOOP UNTIL (TIMER - T!) >= .2
    NEXT
END SUB
Thus making it a routine for the program to use.... You see how the library works above I hope,.. same thing, except its outside the code included in....

:wink:
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

A routine is also commonly known as a procedure, aka: Sub or function.
I have left this dump.
... or guest or ????

Post by ... or guest or ???? »

o
so it's like a sub
just to make things easier
User avatar
The Awakened
Veteran
Posts: 144
Joined: Sun Aug 07, 2005 1:51 am

Post by The Awakened »

Yes, but often times libraries are written in a different programming language, especially assembly, to make things like drawing graphics really fast, or to do things like sound and music that would otherwise take a lot of study and expermentation.
"Sorry for beating you up with a baseball bat Julian, but I DID think that you were a samsquanch."
... or guest or ????

Post by ... or guest or ???? »

o i think i get it more now
o yeah is there an easier way to do graphics than using that data table thingy because it takes forever to draw 1 small picture
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Re: what are libraries?

Post by Nodtveidt »

... or guest or ???? wrote:what are libraries?
Large buildings with many objects inside called "books"...they contain these things called "pages", on which are written "words".

:lol: :lol: :lol: :lol: :lol: :lol: :lol:
MystikShadows
Veteran
Posts: 703
Joined: Sun Nov 14, 2004 7:36 am
Contact:

Post by MystikShadows »

LOL Nek....I'm sure that answered all his questions ;-) LOL
When God created light, so too was born, the first Shadow!

MystikShadows

Need hosting? http://www.jc-hosting.net

Interested in Text & ASCII development? Look no further!
http://www.ascii-world.com
User avatar
The Awakened
Veteran
Posts: 144
Joined: Sun Aug 07, 2005 1:51 am

Post by The Awakened »

... or guest or ???? wrote:o i think i get it more now
o yeah is there an easier way to do graphics than using that data table thingy because it takes forever to draw 1 small picture
Look in the tutorials on Pete's site, specifically on commands like BSAVE, BLOAD, GET, PUT, and stuff like that.
"Sorry for beating you up with a baseball bat Julian, but I DID think that you were a samsquanch."
User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

Post by {Nathan} »

and under the download/utilities section: pp256.
Image
... or guest or ????

Post by ... or guest or ???? »

i did look at those but bload and bsave thingies still need the data table thingy
and i don't get what Nathan mean

and that was really helpful Nek, if i was 10 years younger
User avatar
The Awakened
Veteran
Posts: 144
Joined: Sun Aug 07, 2005 1:51 am

Post by The Awakened »

He said download PixelPlus 256. Excellent pixel art program, although as far as I know, you can only use the graphics it makes in Screen 13... which is pretty much the standard for QB games.
"Sorry for beating you up with a baseball bat Julian, but I DID think that you were a samsquanch."
User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

Post by {Nathan} »

no... you can bload in any screen mode, you just haave to remember to only use certain colors. and some games use screen 7 and 0.
Image
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

... or guest or ???? wrote:and that was really helpful Nek, if i was 10 years younger
Yes, I agree with Dave.. way to go Nek.. *shakes head*
I have left this dump.
Post Reply