doubts about globals, seeking advise...
J. Landman Gay
jacque at hyperactivesw.com
Sat Jan 3 17:44:21 EST 2004
On 1/4/04 3:52 AM, Andre Garzia wrote:
> 4) When run, everything explodes... The stack cannot find tDatabaseID
> (declared as global in both stacks, outside the handlers) so it throws
> an error that
> database is not opened. But in openStack I use this code:
>
> -- open the database connection.
> if tDatabaseID is empty then
>
> get revOpenDatabase("MySQL", "blablabla", "blablabla", "blablabla"
> ,"blablabla")
> if it contains "err" then
> answer "Cannot open database: " & it
> exit openStack
> else
> put it into tDatabaseID
>
> end if
> end if
>
> This code is simple and straight forward, in my handlers I always check
> if tDatabaseID is empty, if so I throw an error... It works inside the
> IDE, also works if make standalone by itself, it's only when put
> together with splashscreen (which does not call any db func) that this
> strange behaviour occours...
This sounds like the common problem where the database external is not
loading at all in the substack. When the splash opens (the mainstack) it
loads the external, but when you close the splash, the external gets
unloaded. Then when the substack opens, there is no external available
for the substack.
You can try adding the database to the externals property of the
substack and sometimes that will work. Sometimes it doesn't. You can
also try hiding the splash instead of closing it; maybe that will force
the external to stay resident in memory. Or you can try moving all your
database handlers into the splash stack script, where they will be
available everywhere.
I have entered a Bugzilla enhancement request that asks that we be able
to load externals on demand. That would solve this problem, which seems
to affect just about everybody who tries to use a splash for the
application mainstack with a substack that uses an external. It isn't
just databases either, it happens with any external.
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode
mailing list