.. _set_on_program_stopped: set_on_program_stopped ------------------------------------------ This function registers a callback function that automatically checks whether program execution has been completely terminated when the program is terminated in Auto mode due to an error or a user command. Use it to run your own code automatically when this event occurs. **Definition** |br| ``DRFLEx.h`` within class `CDRFLEx`, public section .. code-block:: cpp void set_on_program_stopped(TOnProgramStoppedCB pCallbackFunc) { _set_on_program_stopped(_rbtCtrl, pCallbackFunc); }; **Parameter** .. list-table:: :widths: 20 20 20 40 :header-rows: 1 * - **Parameter Name** - **Data Type** - **Default Value** - **Description** * - pCallbackFunc - :ref:`TOnProgramStoppedCB ` - - - Refer to definition of callback function **Return** |br| None .. note:: See :ref:`Rules for callback functions `. **Example** .. code-block:: cpp void OnProgramStoppedCB(const PROGRAM_STOP_CAUSE eStopCause) { // Shows whether restart of program is possible } drfl.set_on_program_stopped(OnProgramStoppedCB); When this function is registered, the callback `OnProgramStoppedCB()` is automatically executed whenever a program is stopped. It helps determine whether the program was terminated normally, by user interruption, or due to an error — and can be used to trigger restart or recovery logic accordingly.