like pass, but without ending the handler

Mark Schonewille m.schonewille at economy-x-talk.com
Wed Feb 28 16:42:18 EST 2007


Chipp,

The software I linked to allows you to run Python with Rev. This  
means that you can simply get "the result" frokm the Python script,  
just like with AppleScript and any other OSA language. This makes the  
callback unnecessary.

If you still need a callback, you could call the script that runs the  
Python script with "send in 0 millisecs" and directly after that run  
a repeat loop with messages. The repeat loop can poll for the file  
that contains the result of the Python script. When the file is  
there, continue the handler and return the contents of the new file.

function foo
   put empty into myData
   send  "doYourPythonStuff" to me in 0 millisecs
   put 0 into myCounter
   repeat until (there is a file x) or (myCounter > 100)
     wait 100 millisecs with messages
     add 1 to myCounter -- at most 10 secs
   end repeat
   if there is a file x then
     open file x
     read from file x until eof
     close file x
     put it into myData
     delete file x
   end if
   return myData
end foo

Now, the user of your libraries only needs to call the foo() function.

Best,

Mark

--

Economy-x-Talk
Consultancy and Software Engineering
http://economy-x-talk.com
http://www.salery.biz

Get your store on-line within minutes with Salery Web Store software.  
Download at http://www.salery.biz

Op 28-feb-2007, om 22:19 heeft Chipp Walters het volgende geschreven:

> Thanks Mark,
>
> My issue though isn't with Python, but rather how to create an slick
> interface callback system for Rev.
>
> The idea being I would really like to be able to implement in my
> library, in process function calls such as:
>
> put getThisThing() into t1
> put nowGetAnotherThing() into t2
>
> without the developer having to implement a messy callback structure.
> Not sure if this is even possible.
>
> (Or if anyone else could describe a different type of way for handling
> callback 'in process'?)





More information about the use-livecode mailing list