Onload events or openCard

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
cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Onload events or openCard

Post by cusingerBUSCw5N » Mon Aug 06, 2012 6:14 pm

Does LiveCode have any onload events? I want to load an image from the Internet but I don't want to connect it to a button. I want it to automatically load. I looked at OpenCard - but either that isn't the solution or I am putting OpenCard in the wrong spot - because it doesn't work. I was trying a simple test of putting "bob" in a text field with OpenCard and it didn't work either.

on openCard
put "bob" into field "sample text"
end openCard

Sorry for being so dumb.

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

Re: Onload events or openCard

Post by mwieder » Mon Aug 06, 2012 6:27 pm

Hmmm... Nothing wrong with your openCard handler. I take it "bob" isn't going into the field? And that field exists on the card?
Where did you put the openCard handler? You might try something like this to ensure that it's getting called

Code: Select all

on openCard
  answer "openCard!" && the name of this card
end openCard

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Onload events or openCard

Post by sturgis » Mon Aug 06, 2012 6:29 pm

You need to make sure that messages are not turned off. (look at the toolbar see if the messages icon to see if messages are enabled or disabled)

Then make sure your script is either in the card script or the stack script. From the dictionary:
Sent to a card right after you go to the card.
So when it is sent to the card, if there is an opencard handler there it will execute. If there is NO opencard handler, the message will go up the message path to the stack and look for a handler there.

If the opencard handler is in an object it will never fire (unless you explicitly send the opencard message to the object yourself)

And of course if the card is already open when you enter the script, since it is already open the script won't fire.

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

Re: Onload events or openCard

Post by Klaus » Mon Aug 06, 2012 6:30 pm

Hi,

the script DOES of course work! :D

Where did you put it?
As the name suggest, best to put it into the CARD script.

Check this great overview about the message hierarchie in LiveCode:
http://www.fourthworld.com/embassy/arti ... _path.html

Or am I misunderstanding you?


Best

Klaus

cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: Onload events or openCard

Post by cusingerBUSCw5N » Tue Aug 07, 2012 5:40 pm

It works now. I think one of the problems I have had is that I've been using multiple versions of my application with the same names - without using "File" - "Close and remove from memory". Now that I am being more careful to only have one open at a time, I am having fewer problems.

Thanks

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

Re: Onload events or openCard

Post by Klaus » Tue Aug 07, 2012 6:03 pm

Well... 8)

Post Reply