Page 1 of 1

"waiting" for a message

Posted: Sun Apr 26, 2009 8:07 am
by Andycal
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?

Posted: Sun Apr 26, 2009 12:50 pm
by Andycal
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?

Posted: Sun Apr 26, 2009 3:28 pm
by malte
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

Posted: Tue Apr 28, 2009 6:34 am
by Andycal
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?

Posted: Tue Apr 28, 2009 11:00 pm
by Mark Smith
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

Posted: Wed Apr 29, 2009 6:10 am
by Andycal
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!