GLBasic forum

Codesnippets => Userlibs [ *.gbal] => Topic started by: Uncle on 2009-Aug-09

Title: How do I make and include Userlibs?
Post by: Uncle on 2009-Aug-09
Stoopid question alert! I've searched the forum but can't seem to find much info on UserLibs.  I was wondering what exactly are Userlibs, how can I create them, and how do I include them in my project?  Are these libraries written in GLB that I can include in my project e.g. if I wrote a sprite system UserLib I could just plug it into multiple projects?  Are these libraries completely separate from the source code they are plugged into i.e. I could have the same variable name in both the main source and userlibs, but they would be treated as two separate variables? 

Cheers for looking,

Unc

Title: Re: How do I make and include Userlibs?
Post by: trucidare on 2009-Aug-09
Open your Project then you userlib (gbal of other gbas) then rightclick and add to project. thats all. now you can use functions from userlibs and other source files.
Title: Re: How do I make and include Userlibs?
Post by: amarliani on 2009-Aug-09
QuoteI was wondering what exactly are Userlibs, how can I create them, and how do I include them in my project?

Userlibs are simply GLB extension libs made by users themself. To create one, just write your code, than select "Tools/Compress file to Library" from  the GLB menu. (sorry, the menu might actually read a bit different, this is only a translation of my german menu options). Trudicare already explained how to use Userlibs in your projects.

QuoteAre these libraries written in GLB that I can include in my project e.g. if I wrote a sprite system UserLib I could just plug it into multiple projects?

Yes! Thats exactly what userlibs are intended for. 

QuoteAre these libraries completely separate from the source code they are plugged into i.e. I could have the same variable name in both the main source and userlibs, but they would be treated as two separate variables? 

The code is separated from your project, and even more interesting, even not available to any user. So you can hand over (sell?) libs without making your code readable for anyone. Variables: Ahh.. bit more complicated.  As long as your projects variables are LOCAL, yes, you can use the same names. If your project declares a GLOBAL variable with the same name, you will certainly run into problems. Therefore it would be wise to use some sort of unique naming conventions for your lib's variables, e.g. all starting with "usl_" or somthing like that.