LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
nkrontir
- Posts: 15
- Joined: Wed Apr 12, 2006 3:24 am
Post
by nkrontir » Sun Mar 18, 2007 12:15 am
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?
-
malte
- Posts: 1098
- Joined: Thu Feb 23, 2006 8:34 pm
-
Contact:
Post
by malte » Sun Mar 18, 2007 2:00 am
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
-
Klaus
- Posts: 14177
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Sun Mar 18, 2007 12:26 pm
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
-
nkrontir
- Posts: 15
- Joined: Wed Apr 12, 2006 3:24 am
Post
by nkrontir » Sun Mar 18, 2007 1:43 pm
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.