Hi Stephen,
I have a chicken-and-egg situation..
I have a stack startup handler that works fine until it does a 'start
using' for a library stack, and then immediately needs to use a
handler in that stack just included.
What happens is that the code keeps marching along, the lib isn't
active yet... and --- error.
I've put a 'wait 30 ticks' then a 'wait 60 ticks' before continuing.
Not long enough? I know, I know, cheesy too.
What's the best way to allow the lib to load.. and how do I wait or
hold for it?
I know there's an 'librarystack' message..
If this is the standard response from Revolution, my Foole's luck has
kept me from experiencing it: I have not checked all my stacks this
morning; however all but one I checked starts using the Library on
preOpenStack but doesn't call a Library handler until openStack.
Suppose you started using the library stack in preOpenStack and
transferred the library calls to the preOpenCard handler for the first
card opened in your main stack?
I said "all but one" because sdbTools plugIn contains:
on preopenStack
startLibrary "Serendipity_Library.rev"
if the result then
beep
answer warning sdbNoLibraryWarning
close this stack
exit preopenStack
end if
put field "Source Database" of card "Translation" into
translationSource
get the sdbFile of this stack
put it into savedDatabase
put char 1 to -5 of item -1 it into referenceSource
if referenceSource <> translationSource then
put referenceSource into field "Source Database" of card
"Translation"
put empty into field "Destination Database" of card "Translation"
get empty -- trigger db save
end if
if it is not savedDatabase then save this stack
set the icon of button "Serendipity" of card 1 to 103010
try
revGoToFramePaused "GrowBook",1
catch anyError
set the rect of image "Closed book.gif" to 380,45,765,508
end try
getSDBClientId mainStackClientId -- library call
getSDBDbId mainStackDbId -- library call
logInSDBClient (the platform),(the rIPCMode of this stack) -- library
call
checkSDBResult (the result) -- library call
get the result
if word 1 of it then
close this stack
exit preopenStack
end if
put word 2 of it into referenceClientId
put the sdbFile of this stack into savedDatabase
openSDBFile sdbBuffer,false,true,,"None",false,empty -- library call
checkSDBResult (the result) -- library call
get the result
if word 1 of it then
close this stack
exit preopenStack
end if
if the sdbFile of this stack is not savedDatabase then save this stack
put word 2 of it into referenceDbId
put referenceDbId into field "Source Db Id" of card "Translation"
loadToolTips
end preopenStack
This logic has always worked for moi. Perhaps because it isn't
preOpenStack that contains the start using statement, but rather the
startLibrary handler called by preOpenStack. So you might try:
on preOpenStack
...
...
startLibrary "My Library"
callLibraryHandler
...
...
end preOpenStack
startLibrary could be as simple as...
on startLibrary libraryName
start using stack libraryName
return the result
end startLibrary
Mine is more complex:
on startLibrary libraryName
set the itemDelimiter to "/"
put the effective fileName of this stack into libraryPath
put libraryName into item -1 of libraryPath
if there is a stack libraryPath then
start using stack libraryPath
return empty
end if
put "PlugIns" into item -1 of libraryPath
put "/"&libraryName after libraryPath
if there is a stack libraryPath then
start using stack libraryPath
return empty
end if
switch (the platform)
case "Win32"
get specialFolderPath("Documents")&"/"&libraryName
if there is a stack it then
start using stack it
return empty
end if
break
case "MacOS"
if char 1 of the systemVersion < 7 then
delete item -5 to -3 of libraryPath
if there is a stack libraryPath then
start using stack libraryPath
return empty
end if
delete item -2 of libraryPath
if there is a stack libraryPath then
start using stack libraryPath
return empty
end if
end if
break
end switch
return true -- = error
end startLibrary
This is because I want developers who use Serendipity Library to have
multiple optional locations for library placement when bundling it with
their apps.
Rob Cozens
CCW, Serendipity Software Company
"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."
from "The Triple Foole" by John Donne (1572-1631)
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution