Page 1 of 1

Refreshing scrolling fields in "realtime".

Posted: Sun Mar 18, 2007 12:15 am
by nkrontir
Hi.

I'm having an interesting challenge, at least for my standards of transcript knowledge. I want to poll in realtime (or at least refresh every 2 seconds or so) the contents of a file and display them in a scrolling field.

Unfortunately if I put:

Code: Select all

repeat while condition="true"
            read from file mypath&"/somefile.txt" at -1000 until EOF
            put it into field "info_field" 
          end repeat
the program locks up (note that there is a button that when pressed "condition" should have the value "false") and there is nothing I can do but restart Revolution.

Any solutions to this?

Posted: Sun Mar 18, 2007 2:00 am
by malte
Hi,

you might want a timed script here

on startTimer
read from file mypath&"/somefile.txt" at -1000 until EOF
put it into field "info_field"
if condition=true then send "startTimer" to me in 2 seconds
end startTimer

PS: To get out of the repeat loop, try command + period.

Hope that helps,

Malte

Posted: Sun Mar 18, 2007 12:26 pm
by Klaus
Hi krontir,

two important hints:

1. Use parenthesis for concatenating strings, especially for filepaths and object names!
Someties the engine gets confused without them...

-> read from file (mypath & "/somefile.txt")...
-> put empty into field ("fieldname" & var_number)
-> hide button (var_buttonname & "2")

2. If you want to read from a file you have to open it first and cose it after use!

Try this:

on startTimer
open file (mypath & "/somefile.txt") for READ
read from file (mypath & "/somefile.txt") at -1000 until EOF
close file (mypath & "/somefile.txt")
put it into field "info_field"
if condition = true then
send "startTimer" to me in 2 seconds
end if
end startTimer


Hope that heps.


Best

Klaus Major

Posted: Sun Mar 18, 2007 1:43 pm
by nkrontir
Thank you both for this solution, it worked like a charm. I have to ask though,
PS: To get out of the repeat loop, try command + period.
What did you mean by this malte? You completely lost me there. Is it possible to provide an example for future reference?

Thanks.