Page 1 of 1

Starting an App in the Dev IDE

Posted: Wed Jan 16, 2013 10:57 am
by Traxgeek
Hi,

At the risk of becoming an official 'Forum Pest' or as being seen as 'stalking' this Forum...

I have created an app in LC - standard sort of thing I'm sure : multiple controls on a set of cards all within/under my main Stack.
The app accesses/uses an SQLite database and needs accees to said DB before it can 'do anything'...
I have, therefore, (I'm a newbie with limited understanding) put an 'Open the DB' script within the main Stack - in fact the 'Open DB' script is called from within an 'On Startup' script within my Stack script/code area.
Without a valid datbase ID the rest of my scripts pretty much all fail safe and simply report "No Datbase connection..."
When I try to test a script on a card (bearing in mind I need access to the info stored in the Database), say to manipulate / display some data, the said script(s) simply report the default "No Database connection..." unless I have run the main Stack code first.

So, to my question :
Is there a way to start my test from the main Stack (so that I include the 'Open Database' script without having to open the main Stack code window and run this first...
I mean, is there a 'Run' button to emulate the app starting up from scratch (like Run 'Main' - sorry, hangups back to VS !) or do I simply need to display the main Stack each time, run the 'On Startup' script there and then run the 'real' script I want to test after that?
I appreciate the flexibility LC offers with regards to the <Apply> and little green 'Play' button adjacent but in many cases I need the app to 'initialise' itself before any particular sub-Script can be run...

Ideas ? Or am I still talking baloney / missing the obvious ?

TIA

Regards.

Re: Starting an App in the Dev IDE

Posted: Wed Jan 16, 2013 11:49 am
by Klaus
Hi Traxgeek,

problem is the way Livecode loads externals (like the db access)!
This happens AFTER the stack and card have opened!

This way you need to do all this "on opencard", no way to get this
to work earlier (statup or preopenstack)!


Best

Klaus

Re: Starting an App in the Dev IDE

Posted: Thu Jan 17, 2013 6:45 pm
by Traxgeek
Hi Klaus,

Thanks. I think I'll move my DB code from the StacK 'onStartup' area to the Splash page 'onPreOpen' area.

Should be a pretty simple cut'n'paste job I think with an IF THEN/END overrider to see if the DB is already open or not (don't want unnecessary, multiple, simultaneous connections to the DB !)... Sounds simple enough... well, it does now - a week or so after writing it the other way :? !!!

Again. Many thanks.

Regards.