Page 1 of 1

First code run

Posted: Tue Oct 07, 2014 4:26 am
by neatgadgets
Where do I put the first code to be run?

I want to do things like connect to a database, set the dimensions etc

Re: First code run

Posted: Tue Oct 07, 2014 5:03 am
by dunbarx
Whew.

Your question is somewhat like having never been in a car before, and asking "which pedal do I press?"

You must learn at least the basics of LC, its structure, the concept of messages and controls placed on a "card". The concept of a stack. Commands, functions and properties.

Read the user guide and keep the dictionary handy. As a start, create a new mainstack, place a button or two and a field on it, and learn how to place some code in the default mouseUp handler in the button scripts. Create a few gadgets, like placing data into the field, changing that data, etc. Change the properties of the field and the button. In a button handler, try to find as many different events that occur when you move the mouse in and out of the controls on the card, when you click on the button, etc.

Then try to make an address book. Write back in a while when you get stuck on something. You will get infinite help here, but not much tutoring as a total beginner. You have to learn how to start the car, steer and increase and decrease your speed. Oh, and how to brake. Write back, as I said...

Craig Newman

Re: First code run

Posted: Tue Oct 07, 2014 6:53 am
by neatgadgets
Yes I have done all that before. What I want to know is if there is like a pre-start condition, code that is run before all other code is run. Like an OnLoad used in VBA

Re: First code run

Posted: Tue Oct 07, 2014 7:01 am
by neatgadgets
It appears that preOpenStack is what I am looking for.

Re: First code run

Posted: Tue Oct 07, 2014 12:37 pm
by Klaus
Hi neatgadgets,
neatgadgets wrote:It appears that preOpenStack is what I am looking for.
yes, but only "appears" :(

Problem is the way LC loads its own externals and libraries like the database external.
All this stiff is NOT YET loaded on "pre-/openstack" and even "pre-opencard" of the first cd.

The trick is to use a little delay to give the libs time to get loaded, so do somehting like this:

Code: Select all

on opentack
  send "my_database_connect_handler" to me in 100 millisecs
  ## more "normal" openstack stuff here...
end openstack
This way the libs have time to load and the user will not tell the difference :D


Best

Klaus