Re: Repeat Process To Check Contents of File on HTTP Server?
Hi John, I'm assuming the following things are true: * everyone is using Windows, or at least all the kids * all the computers have access to the same shared hard disk, whether it's a file server or one person's computer. * there's a 'GoodLinks' folder on the shared disk where your links to web pages go. * I actually understand what you want to accomplish (that's probably the most iffy part) On those assumptions, you could do this pretty simply. See if the following work flow would accomplish your goal. First, your actions (or "use case" to make it sound more technical): 1. The shared disk is mounted on your computer (and on all the client computers), and you have a shortcut to the shared 'GoodLinks' folder sitting on your desktop. 2. You find a web page you want to share. 3. You drag the web page's icon from the browser URL box onto the 'GoodLinks' shortcut. This creates a "myGreatLink.URL" file in the GoodLinks folder on the server/shared disk. Now the students' actions: 1. When their computers start, a 'Checker' app (see code below) is launched and runs quietly in the background. 2. Checker looks at the names of files in the 'GoodLinks' folder on the shared disk every x seconds (using the "send... in" command). When it finds a new file, it launches it. I think that's everything. Now the code: -- Checker stack script on openStack send "checkForLinks" to me in 5 secs end openStack on checkForLinks -- get all link names set the defaultFolder to "X:/GoodLinks" put the detailed files into tList -- pick the most recently created link filter tList with "*.URL,*" -- to remove non-links from list sort lines of tList numeric descending by item 4 of each put line 1 of tList into tMostRecentLink put item 4 of tMostRecentLink into tMostRecentUpdate -- open link in browser if link is new if tMostRecentUpdate > (the seconds - 5) then launch document (urlDecode(item 1 of tMostRecentLink)) end if -- schedule next execution send "checkForLinks" to me in 5 secs end checkForLinks A few points about this approach: * This way you don't need to store any previous values. * the code assumes that everyone's computer times are close to correct. If some student computer has their clock set to yesterday or tomorrow or last year, this code won't work as expected. * If you're using Macs in the classroom you'll probably need to change the "filter" command to look for a different file type (maybe .webloc), but otherwise it should work. * you notice there's no use of http or sockets - it's all done with file references. I hope I got the problem right! I think accurate problem definition is about 70% of the solution. Phil Davis John Patten wrote: 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 -- Phil Davis PDS Labs Professional Software Development http://pdslabs.net ___ 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
Re: Repeat Process To Check Contents of File on HTTP Server?
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 Subject: Re: Repeat Process To Check Contents of File on HTTP Server? To: How to use Revolution 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 Subject: Re: Repeat Process To Check Contents of File on HTTP Server? To: How to use Revolution Message-ID: 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://your
Re: Repeat Process To Check Contents of File on HTTP Server?
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"; ___ 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
Re: Repeat Process To Check Contents of File on HTTP Server?
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 ___ 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
Repeat Process To Check Contents of File on HTTP Server?
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