Libraries and reusing stacks

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
morbug
Posts: 11
Joined: Tue Oct 07, 2008 6:42 am

Libraries and reusing stacks

Post by morbug » Mon Oct 20, 2008 7:17 am

Sometimes my mind just refuses to understand some things, like the use of Libraries in Rev. I've read lots of forum posts, the user manual, fourthworlds guide but I still don't get it. (I'm very new to Revolution..)

I've created a library stack called libRPG where I've put one function at the moment. My problem is that I can't get my application stack to use it. They're both in the same directory and I've tried using: start using stack "libRPG" and start using stack "libRPG.rev" in the application stack's preOpen handler. The only thing that happens is that I get an error that Rev can't find the object. Obviously I'm misunderstanding something here. Do I have to "import" the stack to my application? If so, how do one import other stacks? I read somewhere that you can use other stacks (that's not in the application) if you supply the filepath but I can't figure out how to do this..

Thanks,

Fredrik

SparkOut
Posts: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Mon Oct 20, 2008 8:29 am

I think if you're working in the IDE then the default location for the "start using" will be relative to the engine location, not the application mainstack, so you'll need to set the folder path for it to find the library stack.
If you have both the application and the library open in memory then in the property inspector for the library stack, under the stack name and title you can select the mainstack. (Or for that matter, in the message box type "set the mainStack of yourLibraryStackName to yourMainStackName".) That will set the library stack as a substack of your application stack and the relative path issue should be resolved.

morbug
Posts: 11
Joined: Tue Oct 07, 2008 6:42 am

Post by morbug » Mon Oct 20, 2008 8:49 am

Thanks!

It works when I use the absolute path to the library. Do you have any thoughts on what's the best way of using libraries in stand-alone applications? Including them as a sub stack?

SparkOut
Posts: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Mon Oct 20, 2008 9:16 am

That's my personal preference, yes. For a standalone though, the relative path will be from the application mainstack, so you can decide as you see fit.

morbug
Posts: 11
Joined: Tue Oct 07, 2008 6:42 am

Post by morbug » Mon Oct 20, 2008 5:57 pm

Thanks again! It looks like a lot less hassle to use the libraries as sub stacks and since I actually got it to work I think I'll use that method.

Post Reply