IonicWind Software

Creative Basic => General Questions => Topic started by: Doc on February 09, 2010, 05:03:02 AM

Title: Creating and using components
Post by: Doc on February 09, 2010, 05:03:02 AM
Since Creative Basic cannot produce compiled DLL's the same way Emergence does, Paul added the "Components" feature to allow users to produce something similar to a DLL for use in any Creative Basic program. The help file has all of the specifics to creating and using components and the images below will show how to create or use them from the IDE:

(http://www.docstoolchest.com/creative/Creative Components.png)

(http://www.docstoolchest.com/creative/Creative Components2.png)

(http://www.docstoolchest.com/creative/Creative Components3.png)

Basically the code included in a component is compiled into a special format that works similar to a regular Windows DLL, but that can only be used with Creative Basic. Once you have included a compiled component into your program, all of the subs and routines can be called just as if you wrote the code in your CBA source file.

In addition to making it more convenient to write or share code with other CB users, everything included in the component becomes compiled as part of your standalone executable. Unlike using a DLL, you do not have to include your component with the executable file. :)

One thing to take note of is that you need to keep a separate copy of the source files used to create a component. Once the source has been compiled from the IDE, it can no longer be edited.

See the help file for full details.

-Doc-
Title: Re: Creating and using components
Post by: aurelCB on February 09, 2010, 05:39:40 AM
Doc your overview is not bad but contain one big mistake.
Components are not similiar with DLL then with SLL which is not the same.
From CB help:
QuoteComponents
Components are precompiled Creative BASIC subroutines than can be included into other projects, this allows reusing code many times without having to cut and paste. Components are written like any other Creative BASIC program with the exception that they cannot contain any global variables or definitions. A component is similar to statically linked libraries in other languages such as 'C'. The subroutines in a component can contain DECLARE statements to predefine API calls.

A component is similar to statically linked libraries

I talk to with Zero and he agree that components are similiar to include files in Ebasic.
Title: Re: Creating and using components
Post by: Doc on February 09, 2010, 06:05:22 AM
Well, technically you are correct, but it's more of a matter of personal perception than mistake. In actual usage, there isn't that much difference between the two. (In both cases you make declarations and point to sub routines.)  ;)

QuoteI talk to with Zero and he agree that components are similiar to include files in Ebasic.

Sorry, but that doesn't float. Components are compiled and cannot be edited like include files can be. In actual usage, there isn't that much difference between the two, so again, it's just a matter of personal perspective.

The whole point is that components make it very easy to re-use (or share) code, without the hassles of continually copying & pasting code from one project to another or without having to distribute a separate DLL along with your exe file. It also helps protect the source code from prying eyes, should that be important to you. (In the case you wanted to sell your work as an add on library)

No use splitting hairs over terminology.  ::)

-Doc-
Title: Re: Creating and using components
Post by: aurelCB on February 09, 2010, 09:20:41 AM
No problem Doc i understand ,just observation.. ;)