Thanks Phil and Bjoernke!

That's what I needed..."send" command. Seems so obvious when you see someone else explain it :-)

Now, that I understand send, here's my dilemma. What I'm trying to create is a little app that allows a teacher in the classroom to push out a web site they have loaded in their "teacher" browser out to to all 32 student laptops in their classroom. I thought this would be a perfect implementation for revBrowser, a custom web browser. I remember in the past struggling with Rev and opening sockets to try to get two Rev stacks to talk to each other. I never had very much success with that process so I thought I would try to keep it real basic and utilize web sharing and writing out a text file with the teacher's current web site address and time stamp to the local "web sites" folder. The client (student) computers would check that text file every 5 seconds, continually, and then if the time stamp is different from the last web address and time stamp, load the new web address in the client (student) browser. The key word in those run on sentences is "continually."

In the examples shared, the scripts handlers are opencard and mousedown. They only run, essentially, one time through and after the time stamp is different, the script would end.

I started to mess with an idle handler, but that gets messy real quick. Is what I'm describing possible? To have a script run continually in the background over and over? Or, maybe I'm going at this custom teacher to student web browser thing all wrong? Any ideas greatly appreciated!

Thank you!

John Patten


On May 7, 2009, at 10:00 AM, use-revolution-requ...@lists.runrev.com wrote:


  5. Re: Repeat Process To Check Contents of File on HTTP Server?
     (Phil Davis)

 12. Re: Repeat Process To Check Contents of File on HTTP Server?
     (Bj?rnke von Gierke)



------------------------------

Message: 5
Date: Wed, 06 May 2009 23:31:52 -0700
From: Phil Davis <rev...@pdslabs.net>
Subject: Re: Repeat Process To Check Contents of File on HTTP Server?
To: How to use Revolution <use-revolution@lists.runrev.com>
Message-ID: <4a028058.9010...@pdslabs.net>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

John Patten wrote:
Hi All!

I'm making a little web browser client that needs to check the
contents of a file on a web server. It needs to be able to do this
every 5 seconds or so in the background, and then if the contents
changes in the last line of the file it is checking, it starts another
process in the background. Can this be done in Rev? Would I use two
stacks, one as the browser and one with the repeat loop?

I'm at a loss for what this might look like in a script?

Hi John,

Are you familiar with the "send" command? If not, I think you're about
to be... ;o)


-- prep: since you're looking for a change in data values,
-- you need to store its initial value so you have something
-- to compare to
global gOriginalData


-- and the data check has to be put into motion:
on openCard
  -- store initial value
  put url "http://my.website.com/targetfile.txt"; into gOriginalData
  -- put the data check into motion
  send "checkWebFile" to me in 5 secs
end openCard


-- the data check
on checkWebFile
  -- get fresh copy of the data
  put url "http://my.website.com/targetfile.txt"; into tCurrData
  if (last line of tCurrData <> last line of gOriginalData) then
     send ("startOtherProcess" && tCurrData) to me in 1 sec
  else -- data hasn't changed, so schedule another check
     send "checkWebFile" to me in 5 secs
  end if
end checkWebFile


-- the other background process
on startOtherProcess pChangedData
  -- do your other stuff here
end startOtherProcess


The "send... in" construct 'disconnects' the calling and called handlers
from each other, so the calling one can finish executing before the
called one starts. And by saying "in 5 secs", you insert idle time when the UI can be refreshed & interacted with. It keeps the user from being locked out of the UI due to continuous running of code you might have if
you tried using a repeat loop for data checks.

Hopefully this will get you started.


Thanks in Advance!


John Patten

--
Phil Davis

PDS Labs
Professional Software Development
http://pdslabs.net



------------------------------


Message: 12
Date: Thu, 07 May 2009 15:34:20 +0200
From: Bj?rnke von Gierke <b...@mac.com>
Subject: Re: Repeat Process To Check Contents of File on HTTP Server?
To: How to use Revolution <use-revolution@lists.runrev.com>
Message-ID: <b4a2fc5f-2523-4d98-8818-784299b14...@mac.com>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

I suggest to use the "put" command with the "url" keyword, using a
"send in time" structure:

on mouseUp
  checkWebsite ""
end mouseUp

on checkWebsite thePrev
  put line -1 of url "http://yoursite.com/yourfile"; into theCurrent
  if thePrev <> theCurrent then
    --do your stuff here, it changed!
  end if
  send checkWebsite theCurrent to me in 4.5 seconds
  --slightly less then 5 seconds, assuming the download of the whole
file takes ca. 0.5 seconds
end checkWebsite


Be aware that clicking the button twice would have your code execute
twice every 4.5 seconds, so maybe you should check the pendingMessages
somehwere. The docu on that property also shows on how to stop the
repeating.

On 7 May 2009, at 05:43, John Patten wrote:

Hi All!

I'm making a little web browser client that needs to check the
contents of a file on a web server. It needs to be able to do this
every 5 seconds or so in the background, and then if the contents
changes in the last line of the file it is checking, it starts
another process in the background. Can this be done in Rev? Would I
use two stacks, one as the browser and one with the repeat loop?

I'm at a loss for what this might look like in a script?

Thanks in Advance!


John Patten
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution



--

official ChatRev page:
http://bjoernke.com/runrev/chatrev.php

Chat with other RunRev developers:
go stack URL "http://bjoernke.com/stacks/chatrev/chatrev1.3b3.rev";



------------------------------


End of use-revolution Digest, Vol 68, Issue 15
**********************************************

_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to