Packing externals in standalone?

Interested adding compiled externals from LiveCode and third parties to your LiveCode projects? This is the place to talk about them.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
HPW
Posts: 3
Joined: Tue Nov 28, 2006 12:56 pm
Location: Germany

Packing externals in standalone?

Post by HPW » Mon Dec 04, 2006 7:49 am

I am new to runrev and I am exploring the possibilitys with externals.

Using an external, is it possible to create a single file standalone?
I know that externals are DLL's and must be visible for the OS on calling.
(Must externals exist on startup or on first call? Static/Dynamic binding)
So is there a way to prove at startup if the external exist at a given location and if not, to extract the external to that location to make it work.
Using this approach would make the standalone a 'copy and work' solution.
Hans-Peter

oliverk
Site Admin
Site Admin
Posts: 53
Joined: Mon Feb 27, 2006 2:16 pm
Location: Edinburgh

Post by oliverk » Mon Dec 04, 2006 9:30 am

Hi Hans-Peter,

I think it is possible to do this to some extent. One possible way is as follows:

(Let the external be called myExternal.dll.)

- Put the contents of the file myExternal.dll into a custom property of your stack. You can do this by doing

Code: Select all

set the cExternalData of this stack to url ("binfile:myExternal.dll")
- Handle the startup message in your stack script. This is the only place where you can bind an external dll to your stack without restarting Revolution.

- In the startup handler, check if the dll exists, and if not, output it to disk
using something like:

Code: Select all

put the cExternalData of me into url ("binfile:myExternal.dll")
- Then attach the external to your stack using

Code: Select all

set the externals of me to "myExternal.dll"
- You may want to delete myExternal.dll when the stack is closed

Now you should be able to use the external functions and commands contained within myExternal.dll. You can delete the dll from disk when your program is closed.

Unfortunately it is not possible to attach myExternal.dll before the first call to it, because of the way Revolution works, it has to be done on startup.

Hope this helps.

Regards

Oliver
Oliver Kenyon
Software Developer
Runtime Revolution

Bernard
Posts: 351
Joined: Sat Apr 08, 2006 10:14 pm
Location: London, England

Post by Bernard » Mon Dec 04, 2006 2:48 pm

Oliver thanks for that info. Will it work with OS X externals as well?

HPW
Posts: 3
Joined: Tue Nov 28, 2006 12:56 pm
Location: Germany

Post by HPW » Mon Dec 04, 2006 3:27 pm

Oliver, also thanks for the info.
- You may want to delete myExternal.dll when the stack is closed
Where is it done in RunRev?

From other development-enviroments I know that I have to unload a DLL to reset windows reference counter to be able to delete a DLL.
So a DLL in use can't be deleted.
Is it possible with RunRev on ShutDown ?
Hans-Peter

Garrett
Posts: 386
Joined: Sat Apr 08, 2006 8:15 am
Contact:

Post by Garrett » Mon Dec 04, 2006 8:16 pm

Also, is it correct to assume that anything you bind to your rev executable
is loaded into memory when the rev executable ran? So the more you add
to your Rev executable, the more memory your program will require and
use.

-Garrett

stevenp
Posts: 26
Joined: Wed Jan 31, 2007 3:29 am

Post by stevenp » Fri Feb 09, 2007 6:43 am

HPW wrote:Oliver, also thanks for the info.
- You may want to delete myExternal.dll when the stack is closed
Where is it done in RunRev?

From other development-enviroments I know that I have to unload a DLL to reset windows reference counter to be able to delete a DLL.
So a DLL in use can't be deleted.
Is it possible with RunRev on ShutDown ?
You are referring to an ActiveX DLL. They use reference counting. Plug-ins generally use standard DLL's (unless they do something non-standard and fancy.)

The fact is, there are ways to dynamically create and use standard DLL's. I am surprised there's no plug-in that allows you to do that yet. Eventually I'll look into creating plug-ins and see what it'd take to do this.

stevenp
Posts: 26
Joined: Wed Jan 31, 2007 3:29 am

Post by stevenp » Fri Feb 09, 2007 6:45 am

BTW, "hi" Garret. I'm on some other boards that you're on. :)

Garrett
Posts: 386
Joined: Sat Apr 08, 2006 8:15 am
Contact:

Post by Garrett » Fri Feb 09, 2007 7:35 pm

stevenp wrote:BTW, "hi" Garret. I'm on some other boards that you're on. :)
Hey Hi :-)

mvanhoudt
Posts: 11
Joined: Wed Jul 26, 2006 4:08 pm
Contact:

Post by mvanhoudt » Mon Feb 12, 2007 5:25 pm

This is just an addition to Oliver's post.

You can load externals dynamically when they are required. For example using a simple handler:

Code: Select all

on loadExternal pDLL
  -- Use "the externals" property of the templateStack to set the DLL
  set the externals of the templateStack to pDLL
  set the name of the templateStack to (the short name of this stack & "_ExternalWrapper")
  create stack
  -- library stack this stack to insert the external commands and functions into the message path..
  start using stack (the short name of this stack & "_ExternalWrapper")
end loadExternal
and a similar unload handler:

Code: Select all

on unloadExternal pDLL
  stop using stack (the short name of this stack & "_ExternalWrapper")
  delete stack (the short name of this stack & "_ExternalWrapper")
end unloadExternal
The DLL can of course be stored in a custom property and saved out to a file. Be careful with this approach if the DLL is particularly big as the custom property will be loaded into memory.
Marcus van Houdt
Software Developer at Runtime Revolution
marcus@runrev.com

Post Reply

Return to “Using Externals”