| Basic4ppc libraries reference | Basic4ppc Home | Forum |
A Basic4ppc library
Generally, A library is a file that contains software code and data that can be used by various programs. For example, a library that holds functionality for Internet-connections might be used by several programs running and accessing the Internet at the same time.
A Basic4ppc library is the same: a collection of Subs contained in a separated file which can be used by many programs. In order to use the code held in such a file, you add it to your Basic4ppc project, then add an object from the library's objects (which is similar to declaring a variable), and then create an instance this object, using a constructor. Then you call the Subs encapsulated inside this file. For example: suppose two different programs need the ability to draw charts. It is then reasonable for both to add the Charts library to the project, thus importing a large amount of new subs otherwise unsupported. Changes carried out later inside the Charts library will affect all next compilations of the using applications, and there will be no need to maintain duplicate code.
What are libraries made of?
Libraries are just like any other software code. The main difference from a regular Basic4ppc program is that libraries cannot be run separately (they lack the App_Start sub), as a stand-alone program. Their Subs must be called by a caller program. This can be compared to taking out of the main source file a big group of Subs and use them as "external" code. Basic4ppc libraries are made of Microsoft's .net dll files that are built especially for accessing them from a Basic4ppc program. Read more about implementing a Basic4ppc library.
What are libraries good for?
Using libraries enables you to:
Reuse code: write once, use many times.
Use other people's code.
Enjoy extended functionality.
Save time and maintenance efforts.
Simplify upgrades.
Are there drawbacks?
There are:
Dependency: in order to deploy your software you should deploy the relevant library as well. Same is true with compiling and running. The program is no longer self contained, and might experience problems if the needed library is absent. Basic4ppc usually overcomes this issue through the practice of Merging libraries.
Versioning issues: even when found, a library might be of an inaccurate version. This is not always known until too late.
Complexity: rather than having everything wrapped together at your project you use external code, and you have to find out how to use it.
Documentation: being developed by community members and not only by Anywhere software, Libraries documentation depends on the developer's good will.
Types of libraries:
Basic4ppc introduces two main types of libraries: desktop libraries and device libraries. The difference is a result of the differences between the Microsoft Mobile .NET compact framework (CF) and the full version. Not all functionality found in the full version is supported in the compact framework's version. In some cases, those differences led to the development of two files with a similar name. Such a case is the Serial library. There are two files for it - SerialDesktop.dll and SerialDevice.dll. The usage is demonstrated in the next section: Using a library in a Basic4ppc project.
| Basic4ppc libraries reference | Basic4ppc Home | Forum |