External Dll does not refer to correct location. Please Help

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
pkmittal
Posts: 111
Joined: Thu Feb 08, 2007 11:27 am
Contact:

External Dll does not refer to correct location. Please Help

Post by pkmittal » Tue Jul 31, 2007 7:53 am

Hello,

I want to use XML libary in my revolution stack. I have manually copied revxml.dll file to "My Data" folder which is located in the current directoy of standalone.

I am using the following code in OpenStack
put defaultFolder &"/My Data/" into DataFolderPath
put DataFolderPath & "revxml.dll" into myDLLfilePath
set the externals of me to into myDLLfilePath

When I run the standalone then It seems to refer dll from the path C:\Program Files\Revolution 2.6\My Data\revxml.dll because standalone for xml works fine when revxml.dll is located in My DATA folder present in revolution 2.6 directory.

Can you please help me in making this dll refer to correct path.

I have found the following thread for loading the dll in custom propery and then loading it at run time. do we really need to do that ?
http://forums.runrev.com/phpBB2/viewtop ... revxml+dll

Please let me know How I can bind revxml.dll from My Data folder present in standalone directory

Thanks for your help
Best Regards
Pradeep

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Tue Jul 31, 2007 9:49 am

Dear Pradeep,

Setting the externals property in the openStack handler doesn't work. If you read the documentation about the externals property, you will read that you would have to close and reopen the stack.

The following seems to work, although I believe it is undocumented.

Create a new stack "Externals Lib". Put a startUp handler into the card script of card 1 of the mainstack.

Code: Select all

on startUp
  put defaultFolder &"/My Data/" into DataFolderPath
  put DataFolderPath & "revxml.dll" into myDLLfilePath
  set the externals of stack "Externals Lib" to into myDLLfilePath
  send "openLib" to me in 0 millisecs
  pas startUp
end startUp
Also add the following handler to the script of the same card:

Code: Select all

on openLib
  go invisible stack "Externals Lib" in new window
  go back
end openLib
This way, you can load an external without closing and reopening the stack.

You don't need to load an external into a custom property.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Klaus
Posts: 14206
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Tue Jul 31, 2007 11:59 am

Dag MArk, salaam Pradeep,

The "startup" handler is the only place where you can set the external of your mainstack and then can use the externals afterwards, so messing around with a substack is not necessary!

So this is all you need:

Code: Select all

on startUp 
  put defaultFolder &"/My Data/" into DataFolderPath 
  put DataFolderPath & "revxml.dll" into myDLLfilePath 
  set the externals of this stack to myDLLfilePath
  pass startUp 
end startUp
I do this in all of my standalones and never had problems!

Best

Klaus

pkmittal
Posts: 111
Joined: Thu Feb 08, 2007 11:27 am
Contact:

My Data folder for dll is not ready when appplication loads

Post by pkmittal » Tue Jul 31, 2007 12:07 pm

Dear Mark,

Thanks for the solution. I tried your code in plain stack and it seems to work fine.

But In my main application, "My Data" folder is downloaded when I clicked on authenticate button on first card. So I can not use startup handler that because I do not have dll at that time.

Once the atuthenticate is successful then "My Data" is downloaded with the revxml.dll etc. and then it opens up another substack which uses the xml features.

Is there any way, so that I can bind the dll at some other place (after the first card )?

Any trick/solution to do that in rev?

Thanks
Best Regards
Pradeep

Klaus
Posts: 14206
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Tue Jul 31, 2007 12:30 pm

Salaam Pradeep,

in that case you can use this handler right after the dll has been downloaded (succesfully ;-)):

Code: Select all

on create_externals_stack_and_use_it_right_away
  put defaultFolder &"/My Data/" into DataFolderPath 
  put DataFolderPath & "revxml.dll" into myDLLfilePath
  create invisible stack "Externals Lib"
  set the externals of stack "Externals Lib" to myDLLfilePath 
  start using stack "Externals Lib"
end create_externals_stack_and_use_it_right_away
You can of course use a shorter name for the handler ;-)


Regards

Klaus

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Tue Jul 31, 2007 12:31 pm

Hi Pradeep,

In your case, the solution with a dll stored in a custom property might be exactly what you need. Distribute the standalone with the dll in a custom property and write the dll to disk on startUp. Then continue the startUp handler as I explained above.

Klaus, I tried loading the revFont external without separate substack and it didn't work.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Klaus
Posts: 14206
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Tue Jul 31, 2007 12:33 pm

Dag Mark,

hmmm, in the "startup" handler?
This is the official palce to do so...

I do this all the time in my apps and it always worked for me...?
Last edited by Klaus on Tue Jul 31, 2007 12:34 pm, edited 1 time in total.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Tue Jul 31, 2007 12:33 pm

Klaus posted another reply while I was writing my answer. Sure, you can also download the dll from a server rather than store it in a custom property.

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Tue Jul 31, 2007 12:59 pm

Gutentag Klaus,

Sure I believe you and I don't know why it didn't work for me, but I do think that using a substack is the safest way to get it to work. Are you using MetaCard perhaps?

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Klaus
Posts: 14206
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Tue Jul 31, 2007 1:11 pm

Hi Mark,

yes, I am always using MetaCard ;-)
But this works for me even if I let REV build my standalones!

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Tue Jul 31, 2007 2:37 pm

Hi Klaus,

If I ever find out why it doesn't always work for me, I'll let you know.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply