// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab // Copyright (C) 2007-2008 - INRIA // Copyright (C) 2009-2011 - DIGITEO // // This file must be used under the terms of the CeCILL. // This source file is licensed as described in the file COPYING, which // you should have received as part of this distribution. The terms // are also available at // http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt // Main Scilab initialisation file mode(-1); // silent execution mode // clean database when restarted ====================================== predef("clear"); //unprotect all variables clear // erase all variables clearglobal(); // Set stack size =================================================== function setStackSize() defaultstacksize = 10000000; old = stacksize() params = sciargs(); nparam = find(params == "-mem"); if (nparam) then ierr = execstr("newstacksize=" + params(nparam + 1), "errcatch"); if (ierr == 0) then if old(1) <> newstacksize then stacksize(newstacksize); end else if old(1) <> defaultstacksize then stacksize(defaultstacksize); end end else if old(1) <> defaultstacksize then stacksize(defaultstacksize); end end endfunction setStackSize(); clear setStackSize; // Special variables definition ======================================= oldieee=ieee() ieee(2); %inf = 1/0; ieee(0); %nan = %inf-%inf; // boolean variables %T = %t; %F = %f; %tk = (with_module("tclsci") & getscilabmode() <> "NWNI"); ieee(oldieee); clear oldieee // Default Obsolete Warning policy =================================== global %modalWarning; // False -> Scilab will only display a Warning message in the console // if warnings are enabled [warning("on"/"off")]. // True -> Scilab will show a blocking popup. %modalWarning = %F; clear %modalWarning; // Create some configuration variables ================================ PWD = pwd(); // Startup message =================================================== if (sciargs() <> "-nb") & ~fromjava() & ~fromc() & getscilabmode() == "STD" then write(%io(2),[" ";gettext("Startup execution:")]); write(%io(2),gettext(" loading initial environment")); end if ((getscilabmode() == "NWNI" | getscilabmode() == "NW") & ~fromjava() & ~fromc() & sciargs()<>"-nb") [v, opts] = getversion() write(%io(2), strsubst(v, "scilab-", "Scilab ") + " (" + opts($-1) + ", " + opts($) + ")"); clear v opts; end // loads modules ====================================================== modules = getmodules(); // Map 'load' to 'old binary files load' called %_load to be able to load Scilab libraries warning("off"); load = %_load; warning("on"); for i=1:size(modules,"*") startFile = "SCI/modules/" + modules(i) + "/etc/" + modules(i) + ".start"; ierr=exec(startFile, 'errcatch', -1); if ierr <> 0 then disp(msprintf(gettext("Failed to execute %s:"),startFile)); disp(lasterror()); exit(2); end end // Fix for bug #12842: to be removed in Scilab 6 function bug_12842() execstr("[%__variableList__, %__varB__, %__varC__, %__varD__] = listvarinfile(""SCI\modules\atoms\macros\atoms_internals\lib"")", "errcatch"); endfunction bug_12842(); clear bug_12842 clear modules i load ierr startFile; // Create some configuration variables ================================ home = getenv("HOME", SCI); if getos() <> "Windows" then if getenv("PRINTERS", "ndef") == "ndef" then setenv("PRINTERS", "lp"); end end setenv("VERSION", getversion()); // ATOMS =============================================================== if with_module("atoms") then atomsSystemInit(); if sciargs() <> "-noatomsautoload" then atomsAutoload(); clear atomsAutoload; end clear atomsSystemInit; end // Protect variable previously defined ================================ predef("all"); // At startup, no interactive vertical paging by default. ============== lines(0); // load contrib menu if present ======================================== function loadContrib() if isfile(SCI+"/contrib/loader.sce") then global %toolboxes; global %toolboxes_dir; exec(SCI+"/contrib/loader.sce"); end endfunction loadContrib(); clear loadContrib; // calling user initialization ========================================= if sciargs()<>"-nouserstartup" then startupfiles = [ SCIHOME + filesep() + ".scilab" ; .. // Home directory startup SCIHOME + filesep() + "scilab.ini" ]; // "" "" startup if SCIHOME <> pwd() then startupfiles = [ startupfiles ; .. ".scilab" ; .. // Working directory startup "scilab.ini" ] ; // "" "" startup end for i = 1:size(startupfiles, "*") if isfile(startupfiles(i)) then exec(startupfiles(i),-1); end end clear i; clear startupfiles; end // Menus/toolbar can now be enabled ==================================== if getscilabmode() == "STD" then setmenu(gettext("&File")); setmenu(gettext("&Edit")); setmenu(gettext("&Preferences")); setmenu(gettext("&Control")); setmenu(gettext("&Applications")); if ~with_module("scinotes") then // Desactivate Editor menu unsetmenu(gettext("&Applications"), 1); end if ~with_module("xcos") then // Desactivate xcos menu unsetmenu(gettext("&Applications"), 3); end if ~with_module("m2sci") then // Desactivate mfile2sci menu unsetmenu(gettext("&Applications"), 5); end if ~with_module("atoms") then // Desactivate atoms menu unsetmenu(gettext("&Applications"), 7); end setmenu(gettext("&?")); setmenu(gettext("&Toolboxes")); toolbar(-1, "on"); end // ==================================================================== clear ans