1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
// 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
|