running code on image starts and quitting

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

running code on image starts and quitting

raffaello.giulietti
Hi guys,

I need to run some Pharo code whenever the image starts. Similarly on
(clean) quitting.
What's the recommended practice?

Regards
RG

Reply | Threaded
Open this post in threaded view
|

Re: running code on image starts and quitting

CyrilFerlicot
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


signature.asc (817 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: running code on image starts and quitting

Sven Van Caekenberghe-2
You also have to register with SessionManager (see its class comment, see its references).

> On 21 Feb 2017, at 17:10, Cyril Ferlicot D. <[hidden email]> 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
>
> http://www.synectique.eu
>
> 2 rue Jacques Prévert 01,
> 59650 Villeneuve d'ascq France
>


Reply | Threaded
Open this post in threaded view
|

Re: running code on image starts and quitting

raffaello.giulietti
In reply to this post by CyrilFerlicot
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?



Reply | Threaded
Open this post in threaded view
|

Re: running code on image starts and quitting

CyrilFerlicot
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


signature.asc (817 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: running code on image starts and quitting

raffaello.giulietti
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