Read from process

Bob Sneidar bobs at twft.com
Thu Mar 29 11:53:21 EDT 2012


This would be a perfect application of my idea of creating a standalone that does one task. Build a standalone that does what you want, and set it's window to System so it floats above everything else (or not if you want the user to be able to switch back and forth). Use Applescript to communicate with it. Have it output to a text file so you can retrieve the results later if you like. I don't know if Windows has a way of doing that or not. 

Bob


On Mar 28, 2012, at 6:01 PM, Glen Bojsza wrote:

> Hi Mike,
> 
> Well using your code I get the expected result at the end of the process
> but the interim output that I try to capture shows nothing?
> 
> So good news - using your method I get the end result and the user is free
> to do other things  ; / bad news - I can't show the interim output for
> feedback.
> 
> If I use the following code I get the opposite effect - user cannot do
> anything until the process completes but the interim output updates to the
> field.
> 
> In both cases the process completes with the final results.
> 
> So it has to do with the timing of the send and the reading of the process
> (I also tried reading lines and have the same result as reading characters
> as shown below)
> 
> local nM
> on mouseUp
>   startProcess
> end mouseUp
> 
> command startProcess
>   put fld dbPathList into nM
>   open process nM for update
>   set the cRunning of this card to true
>   readloop
> end startProcess
> 
> command readloop
>   if the the cRunning of this card then
>      read from process nM for 10
>      if it is not empty then
>         put it & cr after fld mergeOut
>         put the number of lines of fld mergeOut * 16 into sPlace
>         set the vscroll of fld mergeOut to sPlace
>         if it contains "dblink disconnecting" then
>            set the cRunning of this card to false
>            close process nM
>            exit to top
>         end if
>         send "readloop" to me in 1 tick
>      end if
>      end if
> 
> end readloop
> 
> On Wed, Mar 28, 2012 at 5:35 PM, Mike Bonner <bonnmike at gmail.com> wrote:
> 
>> Sorry for posting and falling off the earth. A bit sick today but will try
>> and give the gist of a send in time loop. This is just off the top of my
>> head and as always there are probably better ways to do this (also as I
>> mentioned before, not sure which forms of read will block and which won't
>> so your mileage may vary depending on need)
>> 
>> command startProcess
>> ## code to connect to the process
>> open process "myprocess" for update
>> ## check for errors opening the process, if no errors then
>> set the cRunning of this card to true -- a method to break the loop, set to
>> false to stop the loop
>> 
>> readloop -- handler to do the read
>> end startProcess
>> 
>> command readloop
>> if the the cRunning of this card then
>> read from process "myProcess" until empty
>> if it is not empty then
>> #do whatever you want with the resulting read.
>> #if the end line is read, close process set the cRunning of this card to
>> false
>> end if
>> send "readloop" to me in 1 tick
>> end if
>> 
>> end readloop
>> 
>> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list