9.4. Control Button Functionality - start_stop

   /*--------------------------------------------------------------------
    * Function:    start_stop
    * Returns:     t or nil
    * Description: Used by control buttons to call the start_process()
    *              and stop_processes() functions.
    *------------------------------------------------------------------*/
   function start_stop(button, prog, process_name, args...)
   {
     local child;
     
     if (button.switched_on())  
       start_process (button, prog, process_name, args);
     else
       stop_processes(prog, process_name);
   }
   

If a toggle button is pressed in, it becomes active (ie. the switched_on method returns true), and we want its associated process to start. The program calls the start_process function to start the process, passing along the necessary arguments.

If the user untoggles (releases) a toggle button, the switched_on method becomes FALSE, and we call the stop_processes function to stop the process associated with the button.