Page 1 of 1

About to Close Prim (Ruby)

PostPosted: Sun Apr 22, 2018 2:31 pm
by DaveyBoy
Hi Guys

I am trying to use the 'About to Close' prim in conjunction with Ruby in order to auto save some data to file as the program shuts down:

Image

I've set the delay to 2 seconds just for demo purposes although in reality it would be a fraction of a second.

When I close the 'schematic' window it works as expected with the delay,
when I close the main Flowstone window it shuts down instantly without delay,
when exported to .exe it shuts down instantly without delay . . . although the manual says it works in exported exes & plugins.

Am I missing something simple (highly likely :) ) or does the prim not work as it should?

Alternatively is there another way to do this?

Any help much appreciated

Thanks in advance
Dave

Re: About to Close Prim (Ruby)

PostPosted: Sun Apr 22, 2018 11:36 pm
by tulamide
I just made tests with Ruby's kernel method at_exit {}

That's why I have bad news for you. It's not the prim that behaves false, it's Ruby. Unfortunately it seems that DSPRobotics calls Kernel.exit! (note the exclamation mark). Contrary to Kernel.exit, Kernel.exit! ignores all at_exit procedures and directly exits. That's also why I can't offer a Ruby-only solution - because Ruby is the cause!

Re: About to Close Prim (Ruby)

PostPosted: Mon Apr 23, 2018 12:03 am
by DaveyBoy
Thanks for taking the time to look at this Tulamide, very much appreciated.

My small amount of data does actually save without the delay... I was concerned that if I have a large amount of data that the program could close before the data has finished writing.

I'll try and think of another way.

Thanks again T :D

Re: About to Close Prim (Ruby)

PostPosted: Mon Apr 23, 2018 12:28 am
by tulamide
DaveyBoy wrote:My small amount of data does actually save without the delay... I was concerned that if I have a large amount of data that the program could close before the data has finished writing.

That is indeed a possibility when using Ruby to write the file. You should be safe though, if using green only.