About to Close Prim (Ruby)

For general discussion related FlowStone
Post Reply
User avatar
DaveyBoy
Posts: 131
Joined: Wed May 11, 2016 9:18 pm
Location: Leeds UK

About to Close Prim (Ruby)

Post 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
Attachments
Hold Test.fsm
(392 Bytes) Downloaded 893 times
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: About to Close Prim (Ruby)

Post 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!
"There lies the dog buried" (German saying translated literally)
User avatar
DaveyBoy
Posts: 131
Joined: Wed May 11, 2016 9:18 pm
Location: Leeds UK

Re: About to Close Prim (Ruby)

Post 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
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: About to Close Prim (Ruby)

Post 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.
"There lies the dog buried" (German saying translated literally)
Post Reply