"waiting" for a message

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Andycal
Posts: 144
Joined: Mon Apr 10, 2006 3:04 pm

"waiting" for a message

Post by Andycal » Sun Apr 26, 2009 8:07 am

I've got a routine that's repeating through a list of web addresses and performing an action on each one. I need to pause until the web page has loaded and so during testing I used something like this:

Code: Select all

  revbrowserNavigate browserId(), tLine
      wait for 10 seconds with messages
Works, but not satisfactory - I want to be sure the page has loaded. So, I changed it to this:

Code: Select all

revbrowserNavigate browserId(), tLine
      wait until browserDocumentComplete with messages
Compiles OK but it just hangs. Checking the message watcher, the handler's being sent, but my script doesn't seem to notice. Am I missing something?

Andycal
Posts: 144
Joined: Mon Apr 10, 2006 3:04 pm

Post by Andycal » Sun Apr 26, 2009 12:50 pm

Right, I've read the documentation some more and I'm getting the syntax wrong, I can't 'wait for a message' from the looks of it, instead I need to have a message trigger something.

Am I right in that assumption?

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Post by malte » Sun Apr 26, 2009 3:28 pm

Hi Andy,

you are correct. You handle messages that occur (e.g. on mouseUp is the handler, that reacts to the event of the mouseButton being lifted) or you can generate your own events that must be triggered by one of the automatic or user input events.

Hth,

Malte

Andycal
Posts: 144
Joined: Mon Apr 10, 2006 3:04 pm

Post by Andycal » Tue Apr 28, 2009 6:34 am

Right then. Maybe someone can help with this then, 'cos it's got me baffled.

What I wanted to do was to cycle through a list of URLs, load each URL into a browser instance and then wait until it has loaded before doing something with the HTML and then moving onto the next one.

I thought I could 'wait' until a specific message (in this case browserDocumentComplete), but I can't, however there is a general 'wait for messages' form but I don't quite understand how this works because as it's waiting for any message, it'll surely just continue at the slightest nudge.

Anyone know how I could do what I want to do?

Mark Smith
Posts: 179
Joined: Sat Apr 08, 2006 11:08 pm
Contact:

Post by Mark Smith » Tue Apr 28, 2009 11:00 pm

First, I'd point out that generally, if all you want is the html, you can just grab the url into a variable without using the browser:

put url turl into tVariable...

If you do need to take your current approach, you could do something like this:

put this in the script where your handler is.

Code: Select all

local  sPageDone

on browserDocumentComplete
  put true into sPageDone
end browserDocumentComplete
then, check the script local variable sPageDone

Code: Select all

repeat for each line tUrl in tUrlList
  put false into sPageDone
  revBrowserSet "url", tUrl
  wait until sPageDone with messages
  do your stuff
end repeat
That's not tested, but hopefully you get the idea...

Best,

Mark Smith

Andycal
Posts: 144
Joined: Mon Apr 10, 2006 3:04 pm

Post by Andycal » Wed Apr 29, 2009 6:10 am

Gotcha!

That's absolutely what I was after. I thought the 'trigger' approach would be the way and I was trying to pop a variable into a field and look for that. Just needed to make the connection to the wait command which you've just pointed out.

Thanks!

Post Reply