Creating/Using Libraries

Hello everyone. I am beginning to see a need for building a library that would store modules with methods to be able to use throughout a few different programs I have built using Xojo. I have a few questions on whether this is the way to go. The purpose of the library would be to write methods in one place instead of having to change the methods in each of the programs I have. In each of my programs, they would link to the library to get the method it needs. Here’s my questions:

  1. Can I build a library using xojo?
  2. In each of my programs, how do I include the library?
  3. Is there a better way than libraries to accomplish what I described above?

Thanks in advance for any help or advice you can offer.

Look at External Project Items

Code Sharing

I use External Items, as @Steve Koger suggests.

A couple of things to note about External Items.

  • When you “Make External…” a Module from your project, for the purpose of sharing in another project, Modules can only be one-level deep. That is, no sub-modules.
  • Once you have External Items referenced in your various projects, avoid using the “Collect Project Items…” command (under the “File” menu), because that will import your External Items so they are local to your current project and are no longer using the shared code.

Otherwise, short of creating your own Plugins, External Items works pretty well for what you’re asking for.

Good luck!

They can’t contain classes either. A major limitation.

DLL’s ? no

[quote=496592:@Jeffery Lemons]2. In each of my programs, how do I include the library?
[/quote]
externals are one way
I tend to use SVN externals as I can put them in as many projects as I want AND still use normal SVN operations for diffing check in check out etc

depends on what you mean by “better”

some version control systems make it absolutely invisible that you a using shared items and its relatively trivial to set up

yeah … I tried … I really did but :frowning:

Right, I forgot that. Thank you.

But you can make a Class (by itself) as an External Item and then share it.

The same can be done for sub-classed Controls. Like if you make a custom button from a sub-classed Canvas, you can make that custom control External.

Basically, you can have lots of individual External Item files, but you can’t group them under say a single Module (which would be really convenient. But I think there is a Feedback request for this kind of feature somewhere).

esp if you’ve used a namespace to encapsulate a bunch of classes within that namespace, and those classes have private interfaces so classes IN the namespace can use all the capabilities of the classes in the namespace and classes outside it can only see the public api :slight_smile:
its one level of scope that is missing from Xojo - “module” or something similar

There is <https://xojo.com/issue/8265>
Thats the case I tried to fix and you can see comments I left way back when

[quote] October 27, 2010 - 11:04pm UTC
yes
until we spend a lot of time to rewrite the existing file io code to handle this there is a low likelihood this will get changed soon
[/quote]

[quote=496599:@Norman Palardy]
yeah … I tried … I really did :([/quote]

We know and appreciate your efforts Norman, for sure, eh.

[quote=496605:@Norman Palardy]October 27, 2010 - 11:04pm UTC
yes
until we spend a lot of time to rewrite the existing file io code to handle this there is a low likelihood this will get changed soon[/quote]
I guess if we can eventually gain the ability to build our own Plugins using the Xojo language, than we’ll have a whole new way building our own libraries for project sharing purposes.

thats kind of the intent of plugins written in xojo afaict
its only #11 on the roadmap :frowning:

the most wanted item is at the end of the roadmap !!!
thanks Xojo

Sounds like alot of great information everyone thank you. Looks like the best method right now is going to be to export and import unfortunately. Hopefully eventually there will be plugins or something to accomplish this more easily.

why ? you can have as many external items as you want.
just can’t put all in the same file, but une one external file per class/module
it’s easy and very useful to maintain a big app.

You can also import an entire directory at once, which makes large numbers of externals easy to manage.