Re: CLIPS Cleanup functions

30 views
Skip to first unread message

Artem Novikov

unread,
Jul 25, 2012, 12:50:32 PM7/25/12
to clip...@googlegroups.com
I can't find correct solution for catching CLIPS "exit" command in my app too.

среда, 25 июля 2012 г., 20:49:58 UTC+8 пользователь David Rajaratnam написал:
Hi all,

I was hoping someone can point me to the correct function I should use to setup a cleanup function.

I have an external function that I setup using the standard DefineFunction call. But I also want to setup a callback to do some cleaning up when CLIPS exits. 

I've tried both AddCleanupFunction and AddEnvironmentCleanupFunction but neither function seem to be the one I want. Firstly, the external function I  setup doesn't need to be environment aware yet both the above cleanup functions require an environment parameter. To get around this I use the GetCurrentEnvironment function to get the current environment, which when called from UserFunctions isn't NULL so presumably is the right thing to do.

In any case, when I setup my callback with AddCleanupFunction the cleanup function is called straight away (and not on CLIPS exit). This is definitely not what I want :). On the other hand using AddEnvironmentCleanupFunction the callback seems to never get called.

All of which leaves me a bit lost as to what I should do to setup a cleanup function. Any thoughts?

Regards,
Dave R.

CLIPS Support

unread,
Jul 26, 2012, 11:50:53 AM7/26/12
to clip...@googlegroups.com
Use a router (section 7, I/O Router System, in the Advanced Programming Guide). Create a router using AddRouter and supply a function to be called when CLIPS exits (the exitFunction argument). It's not necessary to define any of the other I/O related functions. This is functionality used by the I/O functions such as open (which closes all open files before CLIPS exits), but you can use it for non I/O related purposes.

David Rajaratnam

unread,
Jul 26, 2012, 8:34:34 PM7/26/12
to clip...@googlegroups.com
Thanks. I'll do that. I had seen something in the I/O Router section about cleanup but since I'm not trying to create a new I/O stream I though I was looking in the wrong place.

Cheers,
Dave
Reply all
Reply to author
Forward
0 new messages