|
Post by Mystic on Jan 20, 2014 3:54:32 GMT -5
Situation: I am trying to write a program that will read a file every minute and compare what is in the file with what was in the file at the last reading (Every 10 minutes another program is updating the file I am reading). The problem I am having is when I write something like the following code as an experiment, it seems like it processes the entire code for the time it should run and then it displays the results all at once on the screen. Why is it not printing to the screen for each second like it seems it should? startProcessing$ = time$() WHILE LEFT$(time$(),5) = LEFT$(startProcessing$,5) IF RIGHT$(time$(),2) <> RIGHT$(advance$,2) THEN PRINT time$() PRINT "While " + LEFT$(time$(),5) + " = " + LEFT$(startProcessing$,5) advance$ = time$() END IF WEND PRINT "Finished..." END Guess I should add that I am programming RB on my Mac.  Wondering if it would be better just doing this as a cron job with a Ruby script instead of trying to use RB as a scripting language. *shrug* Thanks in advance
|
|
mmiscool
Full Member
 
Send me a message if you want to help with a WEB OS project
Posts: 106
|
Post by mmiscool on Jan 20, 2014 15:27:22 GMT -5
the following code should suit your needs The following code will advance and loop every 10 seconds. global prodject.name$ prodject.name$ = "test" global prodject.username$
[da.top] x = x +1 print "I am going to wait for a bit" print "this is pass ";x
'this link is necessary. java-script on the client side clicks the link for you link #timerlink, " ", [the.timer.kicked.in] :Call TimeoutLink 10000 wait
[the.timer.kicked.in] 'this is where the timer code makes the thing land print "time for the next round"
goto [da.top]
' this sub was modified slightly from the example I am going to link to below. Sub TimeoutLink msec linkId$ = "#timerlink" html " <script type=""text/javascript""> <!-- var a = document.getElementById('"+linkId$+"'); if (a) window.setTimeout('window.location = a.href', +Str$(msec)+"); //--> </script>" End Sub
runbasic.wikispaces.com/Timer+Replacement
|
|
mmiscool
Full Member
 
Send me a message if you want to help with a WEB OS project
Posts: 106
|
Post by mmiscool on Jan 20, 2014 15:43:54 GMT -5
Run basic produces a static web page that until the user interacts with it there is no new data displayed.
You had no wait statements in your program so there was no chance for the program to render the page. You must have a wait statement if you want to display any data.
The code above uses java script on the the client side. (in the web browser ) and after the specified period of time flows the link.
|
|
|
Post by Mystic on Jan 20, 2014 17:28:14 GMT -5
Thanks for pointing this out. I think this will do nicely! 
|
|
|
Post by Mystic on Jan 20, 2014 22:36:57 GMT -5
My home now technically has a "pulse", and can now "sense" when someone is home when it "sees" their phone in the area. Not a perfect system, but it'll do for now as something to build on.
Next step will be to develop the code for reporting when people come and go, and begin researching a home automated light system for my smart home to start controlling based on who is home.
|
|
mmiscool
Full Member
 
Send me a message if you want to help with a WEB OS project
Posts: 106
|
Post by mmiscool on Jan 21, 2014 17:31:44 GMT -5
How do you sense if there phone is in the area. Do you have rb ping it or some thing with the shell command?
[da.top] x = 0 x = x + check.if.home("192.168.2.5") x = x + check.if.home("192.168.2.18") x = x + check.if.home("192.168.2.12")
if x > 0 then print "some one is home"
'this link is necessary. java-script on the client side clicks the link for you link #timerlink, " ", [the.timer.kicked.in] :Call TimeoutLink 10000 wait
[the.timer.kicked.in] 'this is where the timer code makes the thing land print "time for the next round"
goto [da.top]
' this sub was modified slightly from the example I am going to link to below. Sub TimeoutLink msec linkId$ = "#timerlink" html " <script type=""text/javascript""> <!-- var a = document.getElementById('"+linkId$+"'); if (a) window.setTimeout('window.location = a.href', +Str$(msec)+"); //--> </script>" End Sub
function check.if.home(ip.of.device.to.check$) if instr(upper$(shell$("ping ";ip.of.device.to.check$)),upper$("lost = 0") )> 0 then check.if.home = 1 end function
|
|
|
Post by Mystic on Jan 22, 2014 1:14:19 GMT -5
How do you sense if there phone is in the area. Do you have rb ping it or some thing with the shell command? I cheat and use a Mac App called, "IP Scanner Pro". It saves a report in a CSV format every 10 minutes. I just parse the report for the MAC addresses of the phones my family uses. Not a perfect system, but it works to tell who in the family is home and who is away. After all, my teenage daughters won't go anywhere without their phones. LOL
|
|