1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 2007-2008 - INRIA
3 // Copyright (C) 2009-2011 - DIGITEO
5 // Copyright (C) 2012 - 2016 - Scilab Enterprises
7 // This file is hereby licensed under the terms of the GNU GPL v2.0,
8 // pursuant to article 5.3.4 of the CeCILL v.2.1.
9 // This file was originally licensed under the terms of the CeCILL v2.1,
10 // and continues to be available under such terms.
11 // For more information, see the COPYING file which you should have received
12 // along with this program.
14 // Main Scilab initialisation file
16 mode(-1); // silent execution mode
18 // clean database when restarted ======================================
19 //predef("clear"); //unprotect all variables
20 clear; // erase all variables
23 %tk = (with_module("tclsci") & getscilabmode() <> "NWNI");
25 // Default Obsolete Warning policy ===================================
27 // False -> Scilab will only display a Warning message in the console
28 // if warnings are enabled [warning("on"/"off")].
29 // True -> Scilab will show a blocking popup.
33 // Create some configuration variables ================================
36 // Startup message ===================================================
37 // if (sciargs() <> "-nb") & ~fromjava() & ~fromc() & getscilabmode() == "STD" then
38 if (sciargs() <> "-nb") & getscilabmode() == "STD" then
39 printf("\n\n%s\n", gettext("Startup execution:"));
40 printf(gettext(" loading initial environment") + "\n");
43 //if ((getscilabmode() == "NWNI" | getscilabmode() == "NW") & ~fromjava() & ~fromc() & sciargs()<>"-nb")
44 if ((getscilabmode() == "NWNI" | getscilabmode() == "NW") & sciargs()<>"-nb")
45 [v, opts] = getversion()
46 printf(strsubst(v, "scilab-", "Scilab ") + " (" + opts($-1) + ", " + opts($) + ")\n");
50 // loads modules ======================================================
51 modules = getmodules();
52 for i=1:size(modules,"*")
53 startFile = "SCI/modules/" + modules(i) + "/etc/" + modules(i) + ".start";
54 ierr=exec(startFile, 'errcatch', -1);
56 disp(msprintf(gettext("Failed to execute %s:"),startFile));
61 clear modules i ierr startFile;
63 // Create some configuration variables ================================
64 //home = getenv("HOME", SCI);
65 if getos() <> "Windows" then
66 if getenv("PRINTERS", "ndef") == "ndef" then
67 setenv("PRINTERS", "lp");
70 setenv("VERSION", getversion());
72 // ATOMS ===============================================================
73 if with_module("atoms") then
75 if sciargs() <> "-noatomsautoload" then
79 clear atomsSystemInit;
83 // Protect variable previously defined ================================
86 // At startup, no interactive vertical paging by default. ==============
89 // load contrib menu if present ========================================
90 function loadContrib()
91 if isfile(SCI+"/contrib/loader.sce") then
93 global %toolboxes_dir;
94 exec(SCI+"/contrib/loader.sce");
100 // calling user initialization =========================================
101 if ~or(sciargs()=="-nouserstartup") then
103 startupfiles = [ SCIHOME + filesep() + ".scilab" ; .. // Home directory startup
104 SCIHOME + filesep() + "scilab.ini" ]; // "" "" startup
105 for f = startupfiles'
111 // execute .scilab and scilab.start only
112 // if last exec does not change current directory to SCIHOME
114 usedwd = getPreferencesValue("//general/body/startup", "use");
115 if usedwd=="previous"
116 workingDirectory = getPreferencesValue("//general/body/startup", "previous");
117 elseif usedwd=="default"
118 workingDirectory = getPreferencesValue("//general/body/startup", "default");
120 workingDirectory = pwd();
122 if SCIHOME <> workingDirectory then
123 startupfiles = [ workingDirectory + filesep() + ".scilab" ; .. // Working directory startup
124 workingDirectory + filesep() + "scilab.ini" ]; // "" "" startup
126 for f = startupfiles'
133 clear usedwd f startupfiles workingDirectory
136 // Menus/toolbar can now be enabled ====================================
137 if getscilabmode() == "STD" then
138 setmenu(gettext("&File"));
139 setmenu(gettext("&Edit"));
140 setmenu(gettext("&Preferences"));
141 setmenu(gettext("&Control"));
142 setmenu(gettext("&Applications"));
143 if ~with_module("scinotes") then // Desactivate Editor menu
144 unsetmenu(gettext("&Applications"), 1);
146 if ~with_module("xcos") then // Desactivate xcos menu
147 unsetmenu(gettext("&Applications"), 3);
149 if ~with_module("m2sci") then // Desactivate mfile2sci menu
150 unsetmenu(gettext("&Applications"), 5);
152 if ~with_module("atoms") then // Desactivate atoms menu
153 unsetmenu(gettext("&Applications"), 7);
155 setmenu(gettext("&?"));
156 setmenu(gettext("&Toolboxes"));
159 // ====================================================================