Reading from file/stdin non-blocked?

Gordon Tillman got at mindspring.com
Wed Oct 27 15:09:39 EDT 2004


Howdy K.


On Oct 27, 2004, at 14:04, K wrote:

>
> Is the user space accessible with out the RR IDE?

I think you may have to.  Here is all of the stuff from the script file.

--gordy

constant kReadIntervalSecs = 2
constant kTimeoutMS = 1

local sPath, sDone, sPos



on LogIt pMsg
   put pMsg & return after field "statusLF"
   set the scroll of field "statusLF" to the formattedHeight of field 
"statusLF"
end LogIt

on StartRead
   put false into sDone
   answer file "Select a file"
   put it into sPath
   if sPath is not empty then
     put false into sDone
     open file sPath for text read
     put 1 into sPos
     send "ReadFile"
   else
     put true into sDone
   end if
end StartRead

on StopRead
   put true into sDone
   if sPath is not empty then
     close file sPath
     put "" into sPath
   end if
end StopRead




on ReadFile
   if sDone then exit "ReadFile"

   local tDat, tRes

   read from file sPath at sPos until return in kTimeoutMS milliseconds
   put the result into tRes
   put it into tDat
   add the length of tDat to sPos
   replace return with "" in tDat
   if tDat is not empty then LogIt " DATA=" & tDat
   if not sDone then
     if tRes is empty then
       send "ReadFile" to me
     else
       send "ReadFile" to me in kReadIntervalSecs seconds
     end if
   end if
end ReadFile



More information about the use-livecode mailing list