Scodigo, Inc.

Log In | Register

Cart Items:
0

Idle time code

The FM plugin API has a plugin call for idle time processing, it would be extremely useful to be able to execute PHP code at idle time. Maybe being able to register some PHP code and how often it should be called, which would minimise processing overhead.

What are the chances guys?

Cheers,
Darko.

Idle time code

Micah Woods's picture

We haven't considered this specifically but we have thought about allowing multiple "contexts" or "instances" of PHP which could run in the background. The idea is that you'd be able to create a named context and then have it execute code for you. The context could return it's results immediately or you could allow control to be handed back to FileMaker. If control is handed back to FileMaker, the PHP code could do it's work in the background.

This complicates things a bit and we're also not sure how many people would find this useful so it's not at the top of our list. BTW, we do have some really good stuff planned for our 1.5 release as well as the 2.0 release.

If we could do as you suggest, how would it work? Would it be a separate function or would there be a new param, perhaps "executeOnIdle"? What would happen if a call is made to the plug-in BEFORE idle occurs and thus the code hasn't yet executed? I'm guessing this isn't an issue because the code to execute would be stored and waiting for idle? Would you want to be able to have more than one snippet of code waiting for idle or is one enough?

Regards,
Micah

idletime calls

Thanks for your reply Micah. I would have responded eralier but I (wrongly) assumed that my RSS reader would update on replies. I'm actually very interested in this.

Anyway, let me describe an application of this. I want to load data into FileMaker from an continuously updated external data source. This is fine, but right now I can only check the external source in response to some user action, usually clicking a button. At that point the code polls the source, finds some data and goes through the relatively slow process of loading the data. What would be much better is if after some period of inactivity, the polling was done and data loaded while the user was away or distracted. So I might have a PHP function called PollData, and maybe have the plugin call: PHP_OnIde("PollData();", "polling", 60, 60) where the first param is the PHP code to execute, the second a unique identifer, the third the number of seconds of idle time before the code is executed and the forth the time out. The second paramter lets you change (or remove with an empty string) the idle call after it's been established. That's if you wanted to support more than one idle call, one would be enough to begin with, as long as you could specify the idle time before execution. I think you could delay any calls to PHP while the idle time code was running, and conversely not allow the idle time code to be run while other PHP calls were being made. I don't think these would be particularly onerous restrictions. It would be fairly critical to allow idle time PHP calls to call FM though.

Of course I have no idea of the implementation details involded, but it would seem this might be fairly straight forward, and allow some interesting applications.

The background PHP calls sound good too, quite often you want to do processing which takes a long time, but there's no reason hold up the FM user. It would go well with idle time calls since they could return immediately and pick up the results on the next idle call.

I'm looking forward to the new version!

Cheers,
Darko.

Makes sense

Micah Woods's picture

Thanks for the explanation Darko, I have a better understanding now. If we were to implement this, I'd be tempted to support scheduled execution as well as on idle. Since SmartPill can trigger scripts, this would provide similar functionality to zippScript which is something you may want to check out: http://homepage.mac.com/jkornhaus/filemaker/plugins.html. This may actually provide you with what you’re looking for right now.

I’ll put this on our wish list and definitely keep it in mind for the future. I like the idea and I think it would compliment the plug-in nicely. Thanks for the suggestion!

Regards,
Micah

Thanks

Thanks for the zippScript tip, it looks like just the thing. I don't know why but I seem to have so much trouble Googling plugins. I can usually Google the most obscure stuff, but FM plugins seem to elude me.

Cheers,
Darko.