RE:[Fwd: [ROOT] Exit from macro]

From: Masaharu Goto (MXJ02154@nifty.ne.jp)
Date: Mon Mar 12 2001 - 12:30:36 MET


Hello Jiri,

Thank you for your message.

After 'exit()' is called, Cint stops doing anything. It sets
a flag to block any statement as you observed. Because 'exit()'
is normally used when process is terminated, this is a good behavior
in most of the cases. However in ROOT, process is not terminated by
exit(). It simply stops doing anything.

Fons,
There are 2 options to change this behavior in ROOT.

 - 'exit()' terminates ROOT process
     After calling G__process_cmd() in ROOT's command input,
     if G__return==G__RETURN_EXIT2 then ROOT terminates.

 - 'exit()' exits from current macro. Next macro will be executed normally.
     After calling G__process_cmd() in ROOT's command input,
     reset G__return as G__RETURN_NON.

Both cases, the change has to be made in ROOT source code. 

Fons, Will you take a look at this?

Thank you
Masaharu Goto

>Date: Thu, 8 Mar 2001 09:35:29 +0100 (CET)
>From: Jiri Chudoba <Jiri.Chudoba@cern.ch>
>To: roottalk@pcroot.cern.ch
>Subject: [ROOT] Exit from macro
>
>Hello,
>
>how can I properly exit from macro? I get a strange behaviour with the
>function exit: macro does not execute (I mean the new run of macro) after
>the first usage of exit. I have to quit root and only then the macro
>executes again:
>
>errorHandling.C:
>
>// Test macro for error handling
>
>#include <stdlib.h>
>
>Int_t errorHandling(Int_t error=0) 
>{
>    cerr<<"Error is "<<error<<endl;
>    if (error) {
>// error occurred, exit macro
>       cerr<<"Error in errorHandling macro: "<<error<<endl;
>       exit (EXIT_FAILURE);
>    }
>    cerr<<"No error in the macro"<<endl;
>    return 0;
>}
>
>
>[pcepaip16] ~/macros > root.exe
>  *******************************************
>  *                                         *
>  *        W E L C O M E  to  R O O T       *
>  *                                         *
>  *   Version   3.00/05      6 March 2001   *
>  *                                         *
>  *  You are welcome to visit our Web site  *
>  *          http://root.cern.ch            *
>  *                                         *
>  *******************************************
>
>FreeType Engine v1.x used to render TrueType fonts.
>
>CINT/ROOT C/C++ Interpreter version 5.14.78, Feb 21 2001
>Type ? for help. Commands must be C++ statements.
>Enclose multiple statements between { }.
>root [0] .x errorHandling.C(0)
>Error is 0
>No error in the macro
>(Int_t)0
>root [1] .x errorHandling.C(0)
>Error is 0
>No error in the macro
>(Int_t)0
>root [2] .x errorHandling.C(1)
>Error is 1
>Error in error_handling macro: 1
>(Int_t)1
>root [3] .x errorHandling.C(1)
>root [4] 
>
>-> no output after the command [3].
>
>         Thanks, cheers,
>                               Jiri.
>
>*************************************************************************
>* E-mail address:  Jiri.Chudoba@cern.ch                                 *
>* WWW Homepage  :  http://delphiwww.troja.mff.cuni.cz/chudoba/          *
>* Telephone     :  +41 22 76 72288                                      *
>* Fax           :  +41 22 76 79480                                      *
>*************************************************************************
>



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:39 MET