running code on image starts and quitting
Hi guys, I need to run some Pharo code whenever the image starts. Similarly on (clean) quitting. What's the recommended practice? Regards RG
On 21/02/2017 16:54, Raffaello Giulietti wrote:
Hi guys,
I need to run some Pharo code whenever the image starts. Similarly on (clean) quitting. What's the recommended practice?
Regards RG
Hello! Every classes should be able to override the methods #startUp, #startUp:, #shutDown and #shutDown: in order to do some work. -- Cyril Ferlicot http://www.synectique.eu 2 rue Jacques Prévert 01, 59650 Villeneuve d'ascq France
You also have to register with SessionManager (see its class comment, see its references).
On 21 Feb 2017, at 17:10, Cyril Ferlicot D. <cyril.ferlicot@gmail.com> wrote:
On 21/02/2017 16:54, Raffaello Giulietti wrote:
Hi guys,
I need to run some Pharo code whenever the image starts. Similarly on (clean) quitting. What's the recommended practice?
Regards RG
Hello!
Every classes should be able to override the methods #startUp, #startUp:, #shutDown and #shutDown: in order to do some work.
-- Cyril Ferlicot
2 rue Jacques Prévert 01, 59650 Villeneuve d'ascq France
On 2017-02-21 17:10, Cyril Ferlicot D. wrote:
On 21/02/2017 16:54, Raffaello Giulietti wrote:
Hi guys,
I need to run some Pharo code whenever the image starts. Similarly on (clean) quitting. What's the recommended practice?
Regards RG
Hello!
Every classes should be able to override the methods #startUp, #startUp:, #shutDown and #shutDown: in order to do some work.
Hi Cyril, doesn't seem to work in my case. Just for fun, I try to set a class instance variable to Time current in the class-side #startUp method and quit the image with saving. Upon restarting the image, the class instance variable is still nil. Anything else I have to ensure?
On 21/02/2017 17:29, Raffaello Giulietti wrote:
Hi Cyril,
doesn't seem to work in my case.
Just for fun, I try to set a class instance variable to Time current in the class-side #startUp method and quit the image with saving. Upon restarting the image, the class instance variable is still nil.
Anything else I have to ensure?
As Sven said I forgot that you need to register your class. You can add this in the class side on Pharo 5-6: "protocol: class initialization" initialize super initialize. SessionManager default registerToolClassNamed: self name -- Cyril Ferlicot http://www.synectique.eu 2 rue Jacques Prévert 01, 59650 Villeneuve d'ascq France
On 2017-02-21 17:43, Cyril Ferlicot D. wrote:
On 21/02/2017 17:29, Raffaello Giulietti wrote:
Hi Cyril,
doesn't seem to work in my case.
Just for fun, I try to set a class instance variable to Time current in the class-side #startUp method and quit the image with saving. Upon restarting the image, the class instance variable is still nil.
Anything else I have to ensure?
As Sven said I forgot that you need to register your class.
You can add this in the class side on Pharo 5-6:
"protocol: class initialization" initialize super initialize. SessionManager default registerToolClassNamed: self name
Yep, this makes more sense and, indeed, works. Thanks Raffaello
participants (3)
-
Cyril Ferlicot D. -
Raffaello Giulietti -
Sven Van Caekenberghe