Page 1 of 1
					
				Packing externals in standalone?
				Posted: Mon Dec 04, 2006 7:49 am
				by HPW
				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.
			 
			
					
				
				Posted: Mon Dec 04, 2006 9:30 am
				by oliverk
				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
 
			
					
				
				Posted: Mon Dec 04, 2006 2:48 pm
				by Bernard
				Oliver thanks for that info.  Will it work with OS X externals as well?
			 
			
					
				
				Posted: Mon Dec 04, 2006 3:27 pm
				by HPW
				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 ?
 
			
					
				
				Posted: Mon Dec 04, 2006 8:16 pm
				by Garrett
				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
			 
			
					
				
				Posted: Fri Feb 09, 2007 6:43 am
				by stevenp
				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.
 
			
					
				
				Posted: Fri Feb 09, 2007 6:45 am
				by stevenp
				BTW, "hi" Garret.  I'm on some other boards that you're on. 

 
			
					
				
				Posted: Fri Feb 09, 2007 7:35 pm
				by Garrett
				stevenp wrote:BTW, "hi" Garret.  I'm on some other boards that you're on. 

 
Hey Hi 

 
			
					
				
				Posted: Mon Feb 12, 2007 5:25 pm
				by mvanhoudt
				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.