Rationnalization of the tcl/tk init process and use function instead of a silly globa...
[scilab.git] / scilab / modules / tclsci / sci_gateway / c / gw_tclsci.c
1 /*--------------------------------------------------------------------------*/
2 /* INRIA 2005 */
3 /* Allan CORNET */
4 /*--------------------------------------------------------------------------*/
5 #include <string.h>
6 #include "sciprint.h"
7 #include "Scierror.h"
8 #include "localization.h"
9 #include "gw_tclsci.h"
10 #include "stack-c.h"
11 #include "inisci-c.h"
12 #include "scilabmode.h"
13 #include "callFunctionFromGateway.h"
14 /*--------------------------------------------------------------------------*/
15 extern int TK_Started;
16 /*--------------------------------------------------------------------------*/
17  static gw_generic_table Tab[]=
18  {
19   {C2F(sci_TCL_DoOneEvent),"TCL_DoOneEvent"},
20   {C2F(sci_TCL_EvalFile),"TCL_EvalFile"},
21   {C2F(sci_TCL_EvalStr),"TCL_EvalStr"},
22   {C2F(sci_TCL_GetVar),"TCL_GetVar"},
23   {C2F(sci_TCL_SetVar),"TCL_SetVar"},
24   {C2F(sci_opentk),"opentk"},
25   {C2F(sci_close),"close"},
26   {C2F(sci_findobj),"findobj"},
27   {C2F(sci_TCL_set),"%s_set"},
28   {C2F(sci_TCL_get),"%s_get"},
29   {C2F(sci_TCL_gcf),"TCL_gcf"},
30   {C2F(sci_TCL_scf),"TCL_scf"},
31   {C2F(sci_TCL_GetVersion),"TCL_GetVersion"},
32   {C2F(sci_TCL_UnsetVar),"TCL_UnsetVar"},
33   {C2F(sci_TCL_ExistVar),"TCL_ExistVar"},
34   {C2F(sci_TCL_UpVar),"TCL_UpVar"},
35   {C2F(sci_TCL_DeleteInterp),"TCL_DeleteInterp"},
36   {C2F(sci_TCL_CreateSlave),"TCL_CreateSlave"},
37   {C2F(sci_TCL_ExistInterp),"TCL_ExistInterp"},
38   {C2F(sci_TCL_ExistArray),"TCL_ExistArray"}
39  };
40 /*--------------------------------------------------------------------------*/
41 int C2F(gw_tclsci)()
42 {  
43         if ( getScilabMode() != SCILAB_NWNI )
44         {
45                 if (isTkStarted())
46                 {
47                         Rhs = Max(0, Rhs);
48                         callFunctionFromGateway(Tab);           
49                 }
50                 else
51                 {
52                         sciprint(_("Warning: Problem(s) with TCL/TK interface. Interface not enabled.\n"));
53                 }
54         }
55         else
56         {
57                 Scierror(999,_("Tcl/TK interface disabled in -nogui mode.\n"));
58                 return 0;
59         }
60         
61   return 0;
62 }
63 /*--------------------------------------------------------------------------*/