First code run

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
neatgadgets
Posts: 17
Joined: Sat Dec 21, 2013 12:14 pm

First code run

Post 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
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10501
Joined: Wed May 06, 2009 2:28 pm

Re: First code run

Post 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
neatgadgets
Posts: 17
Joined: Sat Dec 21, 2013 12:14 pm

Re: First code run

Post 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
neatgadgets
Posts: 17
Joined: Sat Dec 21, 2013 12:14 pm

Re: First code run

Post by neatgadgets »

It appears that preOpenStack is what I am looking for.
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: First code run

Post 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
Post Reply