PreOpenCard

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
sandybassett
Posts: 35
Joined: Fri May 31, 2013 7:44 pm

PreOpenCard

Post by sandybassett » Fri Jun 07, 2013 4:35 am

I see mentioned On Openstack and PreOpenCard and I'm guessing this has to do just with the first card where you do some housekeeping preparation invisible to the user. Is that right? If so what seems to be best practice with this?

icouto
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 92
Joined: Wed May 29, 2013 1:54 am

Re: PreOpenCard

Post by icouto » Fri Jun 07, 2013 5:01 am

I'm not too sure I understand your question, but I'll try to help anyway ;-)

The preOpenStack and openStack messages are sent when a stack opens, once.

The preOpenCard and openCard messages are sent whenever a card opens. If the user navigates around your stack, going from one card to another and back again, these messages get sent several times - every time the user enters/returns to a card.

Does that help?

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: PreOpenCard

Post by Klaus » Fri Jun 07, 2013 10:09 am

Hi Sandy,

please check these stacks to get the basics of Livecode:
http://www.hyperactivesw.com/revscriptc ... ences.html


Best

Klaus

sandybassett
Posts: 35
Joined: Fri May 31, 2013 7:44 pm

Re: PreOpenCard

Post by sandybassett » Fri Jun 07, 2013 3:06 pm

Thanks icouto; so it seems that PreOpenCard is not a place (card) but an event (running some commands and settings before anything gets started) which might be the right place to declare global variables and open SQLite etc.

Thanks Klaus that's a big help to me generally (don't know yet if it covers preopencard). A problem I'm having getting started with LC is that I'm a very left-brained linear type person and jumping all around the place (tutorials, resources, dictionary, etc) leaves me hanging with lots of unconnected bits of knowledge then trying to put them together to make sense. Maybe that set of conferences will help me do that.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: PreOpenCard

Post by dunbarx » Fri Jun 07, 2013 4:39 pm

Sandy.

..."PreOpenCard is not a place (card) but an event ..."

Exactly.

Whichever side of the brain you use, "preOpenCard" is a message, not an object, like a card. You simply must know about this sort of thing. You used the term 'event", and broadly, that is what LC is all about, engine and user invoked events that are trapped and handled by scripts.

But you will find that a little practice puts these all in their rightful places, and like learning to read, very soon you simply can. This is advice from someone who uses neither side of his brain at all.

Craig Newman

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: PreOpenCard

Post by mwieder » Fri Jun 07, 2013 5:39 pm

Sandy-

Just ignore what Craig said. Both sides of his brain are fully operational.

At any rate, LiveCode doesn't have what you might consider a "linear" or "procedural" model for coding. Rather, it's event-driven. Think of "messages" and "events" as being the same thing. When the user clicks on a button, the button generates "mouseDown" and "mouseUp" events. You can write handlers for these messages in the button script or you can place them farther down the object hierarchy.

Code: Select all

on mouseUp
  answer "you rang?"
end mouseUp
The openX and preOpenX messages are a bit more complicated to explain in terms of when they're fired off. Common practice is to place the openStack and preOpenStack handlers in the script of the first card in the stack in order to help stay out of trouble.

Code: Select all

-- in the script of card 1
on preOpenStack
  -- do some things here *before* the stack appears on the screen
end preOpenStack

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: PreOpenCard

Post by dunbarx » Fri Jun 07, 2013 6:04 pm

Sandy.

Ignore what Mark said. He is only a gifted programmer and inspiring teacher.

Craig Newman

andrewferguson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 184
Joined: Wed Apr 10, 2013 5:09 pm

Re: PreOpenCard

Post by andrewferguson » Sat Jun 08, 2013 12:21 pm

preOpenCard is sent to a card before it appears on the screen.

openCard is sent to a card once it has appeared on the screen.

Also, there is preOpenStack and openStack, which are sent when the stack is opened, not the card.
Andrew

Post Reply