2d45c827ef688f6db31d01ad3101cc2387fa9c25
[scilab.git] / scilab / modules / tclsci / sci_gateway / c / sci_TCL_DeleteInterp.c
1 /*--------------------------------------------------------------------------*/
2 /* INRIA 2005 */
3 /* Allan CORNET */
4 /*--------------------------------------------------------------------------*/
5 #include "TCL_Global.h"
6 #include "gw_tclsci.h"
7 #include "InitTclTk.h"
8 #include "Scierror.h"
9 #include "localization.h"
10 /*--------------------------------------------------------------------------*/
11 int C2F(sci_TCL_DeleteInterp) _PARAMS((char *fname,unsigned long l))
12 {
13         CheckRhs(0,1);
14         CheckLhs(1,1);
15
16         if (Rhs==1)
17         {
18                 int TypeVar1=GetType(1);
19
20                 if (TCLinterp == NULL)
21                 {
22                         Scierror(999,_("%s: Error main TCL interpreter not initialized.\n"),fname);
23                         return 0;
24                 }
25
26                 if (TypeVar1 == sci_strings)
27                 {
28                         static int l2,n2,m2;
29                         Tcl_Interp *TCLinterpreter=NULL;
30
31                         GetRhsVar(1,STRING_DATATYPE,&m2,&n2,&l2);
32                         TCLinterpreter=Tcl_GetSlave(TCLinterp,cstk(l2));
33                         if (TCLinterpreter==NULL)
34                         {
35                                 Scierror(999,_("%s: No such slave interpreter.\n"),fname);
36                                 return 0;
37                         }
38                         else
39                         {
40                                 Tcl_DeleteInterp(TCLinterpreter);
41                                 TCLinterpreter=NULL;
42                         }
43                 }
44                 else
45                 {
46                         Scierror(999,_("%s: Wrong input argument: String expected.\n"),fname);
47                         return 0;
48                 }
49         }
50         else /* Rhs == 0 */
51         {
52                 if (TCLinterp == NULL)
53                 {
54                         Scierror(999,_("%s: Error main TCL interpreter not initialized.\n"),fname);
55                         return 0;
56                 }
57                 CloseTCLsci();
58                 InitializeTclTk();
59         }
60
61         LhsVar(1)=0;
62         C2F(putlhsvar)();
63
64         return 0;
65 }
66 /*--------------------------------------------------------------------------*/