1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 2012 - DIGITEO - Antoine ELIAS
3 // Copyright (C) 2012 - DIGITEO - Vincent COUVERT
5 // This file must be used under the terms of the CeCILL.
6 // This source file is licensed as described in the file COPYING, which
7 // you should have received as part of this distribution. The terms
8 // are also available at
9 // http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
11 function %_sodload(%__filename__, varargin)
13 function v = getScilabFileVersion(%__filename__)
14 verStr = h5readattr(%__filename__, "/", "SCILAB_scilab_version")
15 [a,b,c,d] = regexp(verStr, "/scilab-.*(\d)\.(\d)\.(\d)/");
16 if size(d, "*") == 3 then
17 v = evstr(d(1)) * 100 + evstr(d(2)) * 10 + evstr(d(3));
19 error("unable to find file version: %s", %__filename__);
23 function [varValues] = %__convertVariable__(varValues, varNames)
24 for i = 1:size(varValues)
25 if typeof(varValues(i)) == "ScilabMatrixHandle" then
26 //convert tlist to handle
27 varValues(i) = createMatrixHandle(varValues(i));
28 elseif typeof(varValues(i)) == "ScilabMacro" then
29 //convert tlist to macro
30 varValues(i) = createMacro(varValues(i), varNames(i));
31 elseif isList(varValues(i)) then
33 varValues(i) = parseList(varValues(i));
38 function result = isList(var)
42 if or(type(var) == [15, 16, 17]) then
49 function varValue = parseList(varValue)
51 if or(typeof(varValue)==["cell","st"]) then
52 if typeof(varValue)=="st" then
53 fieldNames = fieldnames(varValue);
55 fieldNames = varValue;
58 for kField = 1:size(fieldNames,"*")
60 if typeof(varValue)=="st" then
61 fieldValue = varValue(fieldNames(kField));
63 fieldValue = varValue{kField};
66 if typeof(fieldValue) == "ScilabMatrixHandle" then
67 fieldValue = createMatrixHandle(fieldValue);
68 elseif typeof(fieldValue) == "ScilabMacro" then
69 //convert tlist to macro
70 fieldValue = createMacro(fieldValue, "function");
71 elseif isList(fieldValue) then
72 fieldValue = parseList(fieldValue);
75 if typeof(varValue)=="st" then
76 varValue(fieldNames(kField)) = fieldValue;
78 varValue{kField} = fieldValue;
83 elseif typeof(varValue)=="list" then
84 for i = definedfields(varValue)
85 if typeof(varValue(i)) == "ScilabMatrixHandle" then
86 varValue(i) = createMatrixHandle(varValue(i));
87 elseif typeof(varValue(i)) == "ScilabMacro" then
88 //convert tlist to macro
89 varValue(i) = createMacro(varValue(i), "function");
90 elseif isList(varValue(i)) then
91 varValue(i) = parseList(varValue(i));
93 varValue(i) = varValue(i);
97 fieldNb = size(getfield(1, varValue), "*");
98 for kField = 2:fieldNb // Do not inspect first field (field names)
99 fieldValue = getfield(kField, varValue);
100 if typeof(fieldValue) == "ScilabMatrixHandle" then
101 fieldValue = createMatrixHandle(fieldValue);
102 elseif typeof(fieldValue) == "ScilabMacro" then
103 //convert tlist to macro
104 fieldValue = createMacro(fieldValue, "function");
105 elseif isList(fieldValue) then
106 fieldValue = parseList(fieldValue);
108 setfield(kField, fieldValue, varValue);
113 function h = createMatrixHandle(matrixHandle)
115 if typeof(matrixHandle) <> "ScilabMatrixHandle" then
119 for i = prod(matrixHandle.dims):-1:1
121 newItem = createSingleHandle(matrixHandle.values(i));
122 if newItem == [] then
127 if or(fieldnames(matrixHandle.values(i))=="user_data") then // TODO Remove after graphic branch merge
128 if isList(matrixHandle.values(i).user_data) then
129 set(h($), "user_data", parseList(matrixHandle.values(i).user_data));
130 elseif typeof(matrixHandle.values(i).user_data) == "ScilabMatrixHandle" then
131 set(h($), "user_data", createMatrixHandle(matrixHandle.values(i).user_data));
137 function h = createSingleHandle(item)
140 h = createFigure(item);
142 h = createAxes(item);
144 h = createPolyline(item);
146 h = createPlot3d(item);
148 h = createFac3d(item);
150 h = createCompound(item);
152 h = createRectangle(item);
156 h = createChamp(item);
158 h = createSegs(item);
160 h = createGrayplot(item);
162 h = createMatplot(item);
166 h = createLegend(item);
168 h = createText(item);
170 h = createAxis(item);
172 h = createuimenu(item);
174 h = createuicontextmenu(item);
176 h = createuicontrol(item);
178 h = createDatatip(item);
180 h = createLight(item);
182 error("handle of type " + item.type + " unhandled");
190 function h = createFigure(figureProperties)
191 fields = fieldnames(figureProperties);
194 if or(fields=="resize") then
195 if figureProperties.menubar<>"figure" ..
196 | figureProperties.toolbar<>"figure" ..
197 | figureProperties.dockable<>"on" ..
198 | figureProperties.default_axes<>"on" then
199 // File created by Scilab 5.5.0 or more
200 h = figure("menubar", figureProperties.menubar, ...
201 "toolbar", figureProperties.toolbar, ...
202 "dockable", figureProperties.dockable, ...
203 "default_axes", figureProperties.default_axes, ...
206 fields(fields=="menubar") = [];
207 fields(fields=="toolbar") = [];
208 fields(fields=="dockable") = [];
209 fields(fields=="default_axes") = [];
210 fields(fields=="visible") = [];
212 [lnums, fnames] = where();
213 ind = grep(fnames, "xload");
214 xload_mode = (ind ~= []);
215 if xload_mode then // See bug #3975
223 if isempty(winsid()) then
224 h = figure("visible", "off");
232 // Following propeties will be set after all other ones
233 isVisible = figureProperties.visible;
234 fields(fields=="visible") = [];
235 resizefcn = figureProperties.resizefcn;
236 fields(fields=="resizefcn") = [];
237 event_handler = figureProperties.event_handler;
238 fields(fields=="event_handler") = [];
241 fields(fields=="figure_id") = [];
243 h.figure_position=figureProperties.figure_position;
244 fields(fields=="figure_position") = [];
245 // set auto_resize first otherwise viewport modification may not have any effect.
246 h.auto_resize = figureProperties.auto_resize;
247 fields(fields=="auto_resize") = [];
248 h.figure_size = figureProperties.figure_size;
249 fields(fields=="figure_size") = [];
250 // set axes_size last because it's more important than figure_size
251 h.axes_size = figureProperties.axes_size;
252 fields(fields=="axes_size") = [];
254 for i = 1:size(fields, "*")
255 if fields(i) == "children" then
256 c = figureProperties(fields(i));
258 createSingleHandle(c.values(s));
260 xsetech(wrect=[0 0 .1 .1])
261 createSingleHandle(c.values(i));
264 if fields(i)<>"pixmap" then // See bug #13310
265 set(h, fields(i), figureProperties(fields(i)));
270 h.resizefcn = resizefcn;
271 h.event_handler = event_handler;
272 h.visible = isVisible;
278 function h = createLabel(labelProperties, h)
279 fields = fieldnames(labelProperties);
281 for i = 1:size(fields, "*")
282 set(h, fields(i), labelProperties(fields(i)));
289 function h = createTicks(ticksProperties)
290 h = tlist(["ticks","locations","labels"], [], []);
291 fields = fieldnames(ticksProperties);
292 for i = 1:size(fields, "*")
293 h(fields(i)) = ticksProperties(fields(i));
300 function h = createAxes(axesProperties)
301 // Hack to determine whether %h_load has been called by the %h_copy macro
302 // in which case a new Axes object is created
304 [lnums, fnames] = where();
305 ind = grep(fnames, "%h_copy");
306 if ~isempty(ind) then
311 fields = fieldnames(axesProperties);
314 // Get log_flags to be sure to set them after data_bounds
315 log_flags = axesProperties.log_flags;
316 fields(fields=="log_flags") = [];
318 // Get mark_mode to be sure to set it after mark_style
319 mark_mode = axesProperties.mark_mode;
320 fields(fields=="mark_mode") = [];
322 // Get auto_ticks to be sure to set it after ticks labels
323 auto_ticks = axesProperties.auto_ticks;
324 fields(fields=="auto_ticks") = [];
326 if isfield(axesProperties, "auto_margins") then
327 auto_margins = axesProperties.auto_margins;
328 fields(fields=="auto_margins") = [];
332 for i = 1:size(fields, "*")
333 if or(fields(i) == ["title","x_label","y_label","z_label"]) then
334 createLabel(axesProperties(fields(i)), h(fields(i)));
335 elseif or(fields(i) == ["x_ticks", "y_ticks", "z_ticks"]) then
336 set(h, fields(i), createTicks(axesProperties(fields(i))));
337 elseif fields(i) == "children" then
338 createMatrixHandle(axesProperties(fields(i)));
339 elseif fields(i) == "clip_state" then
340 if axesProperties.clip_state=="on" then
341 set(h,"clip_box",axesProperties.clip_box);
343 set(h,"clip_state", axesProperties.clip_state);
344 elseif fields(i) == "clip_box" then
345 // managed with 'clip_state'
346 elseif fields(i) == "data_bounds" then
347 set(h, "data_bounds", axesProperties.data_bounds);
348 set(h, "log_flags", log_flags);
349 elseif fields(i) == "mark_style" then
350 set(h, "mark_style", axesProperties.mark_style);
351 set(h, "mark_mode", mark_mode);
353 set(h, fields(i), axesProperties(fields(i)));;
357 set(h, "auto_ticks", auto_ticks);
359 set(h, "auto_margins", auto_margins);
364 if ~isempty(%LEG) then
365 // Get handles from paths
366 links=getlinksfrompath(h, %LEG.paths)
367 if ~isempty(links) then
368 L = captions(links, %LEG.text)
369 L.visible = %LEG.visible
370 L.font_style = %LEG.font_style
371 L.font_size = %LEG.font_size
372 L.font_color = %LEG.font_color
373 L.fractional_font = %LEG.fractional_font
375 L.legend_location = %LEG.legend_location
376 L.position = %LEG.position
377 L.line_mode = %LEG.line_mode
378 L.thickness = %LEG.thickness
379 L.foreground = %LEG.foreground
380 L.fill_mode = %LEG.fill_mode
381 L.background = %LEG.background
382 if %LEG.clip_state=="on" then
383 L.clip_box = %LEG.clip_box
385 L.clip_state = %LEG.clip_state
386 L.user_data = %LEG.user_data
388 warning(msprintf(_("%s: Legend does not fit with the current context. Skipped\n"), "load"));
398 function h = createPolyline(polylineProperties)
399 fields = fieldnames(polylineProperties);
402 xpoly(polylineProperties.data(:,1), polylineProperties.data(:,2))
406 if polylineProperties.clip_state=="on" then
407 set(h, "clip_box", polylineProperties.clip_box)
409 set(h, "clip_state", polylineProperties.clip_state);
410 fields(fields=="clip_box") = [];
411 fields(fields=="clip_state") = [];
413 if polylineProperties.interp_color_mode=="on" & ~isempty(polylineProperties.interp_color_vector) then
414 set(h, "interp_color_vector", polylineProperties.interp_color_vector);
415 set(h, "interp_color_mode", polylineProperties.interp_color_mode);
417 if ~isempty(polylineProperties.interp_color_vector) then
418 h.interp_color_vector = polylineProperties.interp_color_vector;
420 h.interp_color_mode = polylineProperties.interp_color_mode;
422 fields(fields=="interp_color_vector") = [];
423 fields(fields=="interp_color_mode") = [];
425 // Get mark_mode to be sure to set it after mark_style
426 mark_mode = polylineProperties.mark_mode;
427 fields(fields=="mark_mode") = [];
432 for i = 1:size(fields, "*")
433 if fields(i) == "mark_style" then
434 set(h, "mark_style", polylineProperties.mark_style);
435 set(h, "mark_mode", mark_mode);
436 elseif fields(i) == "children" then
437 createMatrixHandle(polylineProperties(fields(i)));
438 elseif fields(i) == "datatips" then
439 createMatrixHandle(polylineProperties(fields(i)));
441 h(fields(i)) = polylineProperties(fields(i));
445 clearglobal %POLYLINE
452 function h = createPlot3d(plot3dProperties)
453 h = createSurface(plot3dProperties);
459 function h = createFac3d(fac3dProperties)
460 h = createSurface(fac3dProperties);
466 function h = createSurface(surfaceProperties)
467 fields = fieldnames(surfaceProperties);
469 // plot3d modify the axes properties
474 rotation_angles = a.rotation_angles;
475 axes_visible = a.axes_visible;
478 x_label_visible = a.x_label.visible;
479 y_label_visible = a.y_label.visible;
480 z_label_visible = a.z_label.visible;
481 x_label_text = a.x_label.text;
482 y_label_text = a.y_label.text;
483 z_label_text = a.z_label.text;
484 axes_isoview = a.isoview;
486 if (or(surfaceProperties.color_flag==[2 5]) & ~or(fields=="cdata_mapping")) | ..
487 ((surfaceProperties.color_flag>=2) & or(fields=="cdata_mapping")) then
488 plot3d1(surfaceProperties.data.x, surfaceProperties.data.y, list(surfaceProperties.data.z, surfaceProperties.data.color))
490 plot3d(surfaceProperties.data.x,surfaceProperties.data.y,surfaceProperties.data.z)
492 fields(fields=="data") = [];
494 // Restore this properties after plot3d.
495 a.rotation_angles = rotation_angles;
496 a.axes_visible = axes_visible;
499 a.x_label.visible = x_label_visible;
500 a.y_label.visible = y_label_visible;
501 a.z_label.visible = z_label_visible;
502 a.x_label.text = x_label_text;
503 a.y_label.text = y_label_text;
504 a.z_label.text = z_label_text;
505 a.isoview = axes_isoview;
507 // Get mark_mode to be sure to set it after mark_style
508 mark_mode = surfaceProperties.mark_mode;
509 fields(fields=="mark_mode") = [];
513 if or(fields=="cdata_mapping") then // Fac3d specific
514 if surfaceProperties.color_flag >= 2 then
515 set(h, "cdata_mapping", surfaceProperties.cdata_mapping);
517 fields(fields=="cdata_mapping") = [];
520 if surfaceProperties.clip_state == "on" then
521 set(h,"clip_box", surfaceProperties.clip_box);
523 set(h,"clip_state",surfaceProperties.clip_state);
524 fields(fields=="clip_box") = [];
525 fields(fields=="clip_state") = [];
527 for i = 1:size(fields, "*")
528 if fields(i) == "mark_style" then
529 set(h, "mark_style", surfaceProperties.mark_style);
530 set(h, "mark_mode", mark_mode);
532 h(fields(i)) = surfaceProperties(fields(i));
540 function h = createCompound(compoundProperties)
541 fields = fieldnames(compoundProperties);
544 h = glue(createMatrixHandle(compoundProperties.children));
545 fields(fields=="children") = [];
547 for i = 1:size(fields, "*")
548 set(h, fields(i), compoundProperties(fields(i)));
555 function h = createRectangle(rectangleProperties)
556 fields = fieldnames(rectangleProperties);
559 xrect(0,1,1,1); // create the rectangle with dummy values
562 if rectangleProperties.clip_state == "on" then
563 set(h,"clip_box", rectangleProperties.clip_box);
565 set(h,"clip_state",rectangleProperties.clip_state);
566 fields(fields=="clip_box") = [];
567 fields(fields=="clip_state") = [];
569 // Get mark_mode to be sure to set it after mark_style
570 mark_mode = rectangleProperties.mark_mode;
571 fields(fields=="mark_mode") = [];
573 for i = 1:size(fields, "*")
574 if fields(i) == "mark_style" then
575 set(h, "mark_style", rectangleProperties.mark_style);
576 set(h, "mark_mode", mark_mode);
578 h(fields(i)) = rectangleProperties(fields(i));
586 function h = createArc(arcProperties)
587 fields = fieldnames(arcProperties);
590 xarc(0,1,1,1,0,360); // create the arc with dummy values
593 if arcProperties.clip_state == "on" then
594 set(h,"clip_box", arcProperties.clip_box);
596 set(h,"clip_state",arcProperties.clip_state);
597 fields(fields=="clip_box") = [];
598 fields(fields=="clip_state") = [];
600 for i = 1:size(fields, "*")
601 set(h, fields(i), arcProperties(fields(i)));
608 function h = createChamp(champProperties)
609 fields = fieldnames(champProperties);
612 champ(champProperties.data.x, champProperties.data.y, champProperties.data.fx, champProperties.data.fy);
613 fields(fields=="data") = [];
617 if champProperties.clip_state == "on" then
618 set(h,"clip_box", champProperties.clip_box);
620 set(h,"clip_state",champProperties.clip_state);
621 fields(fields=="clip_box") = [];
622 fields(fields=="clip_state") = [];
624 for i = 1:size(fields, "*")
625 set(h, fields(i), champProperties(fields(i)));
632 function h = createSegs(segsProperties)
633 fields = fieldnames(segsProperties);
636 xsegs(segsProperties.data(:,1), segsProperties.data(:,2))
640 if segsProperties.clip_state == "on" then
641 set(h,"clip_box", segsProperties.clip_box);
643 set(h,"clip_state",segsProperties.clip_state);
644 fields(fields=="clip_box") = [];
645 fields(fields=="clip_state") = [];
647 // Get mark_mode to be sure to set it after mark_style
648 mark_mode = segsProperties.mark_mode;
649 fields(fields=="mark_mode") = [];
651 for i = 1:size(fields, "*")
652 if fields(i) == "mark_style" then
653 set(h, "mark_style", segsProperties.mark_style);
654 set(h, "mark_mode", mark_mode);
656 h(fields(i)) = segsProperties(fields(i));
664 function h = createGrayplot(grayplotProperties)
665 fields = fieldnames(grayplotProperties);
668 grayplot(grayplotProperties.data.x, grayplotProperties.data.y, grayplotProperties.data.z);
669 fields(fields=="data") = [];
673 if grayplotProperties.clip_state=="on" then
674 set(h, "clip_box", grayplotProperties.clip_box)
676 set(h, "clip_state", grayplotProperties.clip_state);
677 fields(fields=="clip_box") = [];
678 fields(fields=="clip_state") = [];
680 for i = 1:size(fields, "*")
681 set(h, fields(i), grayplotProperties(fields(i)));
688 function h = createMatplot(matplotProperties)
689 fields = fieldnames(matplotProperties);
692 Matplot(matplotProperties.data);
693 fields(fields=="data") = [];
697 if matplotProperties.clip_state=="on" then
698 set(h, "clip_box", matplotProperties.clip_box)
700 set(h, "clip_state", matplotProperties.clip_state);
701 fields(fields=="clip_box") = [];
702 fields(fields=="clip_state") = [];
704 for i = 1:size(fields, "*")
705 set(h, fields(i), matplotProperties(fields(i)));
712 function h = createFec(fecProperties)
713 fields = fieldnames(fecProperties);
716 fec(fecProperties.data(:,1), fecProperties.data(:,2), fecProperties.triangles, fecProperties.data(:,3));
717 fields(fields=="data") = [];
718 fields(fields=="triangles") = [];
722 if fecProperties.clip_state=="on" then
723 set(h, "clip_box", fecProperties.clip_box)
725 set(h, "clip_state", fecProperties.clip_state);
726 fields(fields=="clip_box") = [];
727 fields(fields=="clip_state") = [];
729 for i = 1:size(fields, "*")
730 set(h, fields(i), fecProperties(fields(i)));
737 function h = createLegend(legendProperties)
739 %LEG = legendProperties;
746 function h = createText(textProperties)
747 fields = fieldnames(textProperties);
750 if textProperties.text_box_mode == "off" then
751 xstring(textProperties.data(1), textProperties.data(2), textProperties.text)
753 xstringb(textProperties.data(1), textProperties.data(2), textProperties.text, textProperties.text_box(1), textProperties.text_box(2))
758 if textProperties.clip_state=="on" then
759 set(h, "clip_box", textProperties.clip_box)
761 set(h, "clip_state", textProperties.clip_state);
762 fields(fields=="clip_box") = [];
763 fields(fields=="clip_state") = [];
765 for i = 1:size(fields, "*")
766 set(h, fields(i), textProperties(fields(i)));
773 function h = createDatatip(datatipProperties)
775 fields = fieldnames(datatipProperties);
778 tip_data = datatipProperties("data");
779 h = datatipCreate(%POLYLINE, tip_data);
781 for i = 1:size(fields, "*")
782 if fields(i) == "data" then
786 set(h, fields(i), datatipProperties(fields(i)));
793 function h = createAxis(axisProperties)
794 fields = fieldnames(axisProperties);
797 if axisProperties.tics_direction == "bottom" then
799 elseif axisProperties.tics_direction == "top" then
801 elseif axisProperties.tics_direction == "left" then
803 elseif axisProperties.tics_direction == "right" then
805 elseif size(axisProperties.xtics_coord, "*") > 1 then
810 fields(fields=="tics_direction") = [];
812 drawaxis(x=axisProperties.xtics_coord,y=axisProperties.ytics_coord,dir=axisdir);
813 fields(fields=="xtics_coord") = [];
814 fields(fields=="ytics_coord") = [];
818 if axisProperties.clip_state=="on" then
819 set(h, "clip_box", axisProperties.clip_box)
821 set(h, "clip_state", axisProperties.clip_state);
822 fields(fields=="clip_box") = [];
823 fields(fields=="clip_state") = [];
825 for i = 1:size(fields, "*")
826 set(h, fields(i), axisProperties(fields(i)));
833 function h = createuimenu(uimenuProperties)
834 fields = fieldnames(uimenuProperties);
839 for i = 1:size(fields, "*")
840 if fields(i) == "children" then
841 children = createMatrixHandle(uimenuProperties(fields(i)));
842 for k=1:size(children, "*")
843 set(children(k), "parent", h);
846 set(h, fields(i), uimenuProperties(fields(i)));
854 function h = createuicontextmenu(uicontextmenuProperties)
855 fields = fieldnames(uicontextmenuProperties);
860 for i = 1:size(fields, "*")
861 if fields(i) == "children" then
862 children = createMatrixHandle(uicontextmenuProperties(fields(i)));
863 for k=1:size(children, "*")
864 set(children(k), "parent", h);
867 set(h, fields(i), uicontextmenuProperties(fields(i)));
875 function h = createuicontrol(uicontrolProperties)
876 fields = fieldnames(uicontrolProperties);
879 if or(fields=="scrollable") then
880 // Properties added in Scilab 5.5.0
881 // - scrollable must be set at creation (for frames)
882 // - contraints & margins must be set before parent
883 h = uicontrol("style", uicontrolProperties.style, ...
884 "scrollable", uicontrolProperties.scrollable, ...
885 "constraints", uicontrolProperties.constraints, ...
886 "margins", uicontrolProperties.margins);
887 fields(fields=="scrollable") = [];
888 fields(fields=="constraints") = [];
889 fields(fields=="margins") = [];
890 h.layout_options = uicontrolProperties.layout_options;
891 fields(fields=="layout_options") = [];
892 h.layout = uicontrolProperties.layout;
893 fields(fields=="layout") = [];
895 h = uicontrol("style", uicontrolProperties.style);
897 fields(fields=="style") = [];
899 for i = 1:size(fields, "*")
900 if fields(i) == "children" then
901 children = createMatrixHandle(uicontrolProperties(fields(i)));
902 for k=1:size(children, "*")
903 set(children(k), "parent", h);
906 set(h, fields(i), uicontrolProperties(fields(i)));
914 function h = createLight(lightProperties)
915 fields = fieldnames(lightProperties);
919 fields(fields=="children") = [];
921 for i = 1:size(fields, "*")
922 set(h, fields(i), lightProperties(fields(i)));
926 // Utility function for legends, copy/paste from %h_load
927 function links=getlinksfrompath(ax,paths)
928 // ax is a handle on an axes entity
929 // paths a list or row vector which gives the set of paths relative to
935 p(1)=p(1)-1// the caption does not exists yet
936 for kp=1:size(p,"*"),
937 if or(e.type==["Axes","Compound"])&p(kp)<=size(e.children,"*") then
954 function macro = createMacro(macroStr, macroName)
956 macroSt = macroStr(3);
957 if macroStr(2) == %t then
962 header = strsubst(macroSt(1), "function ", "");
963 body = macroSt(2:$-1);
967 deff(header, body, flag);
968 execstr("macro = " + macroName);
971 [%__lhs__, %__rhs__] = argn();
972 %__resumeList__ = list();
973 %__resumeVarlist__ = [];
975 error(999, msprintf(gettext("%s: Wrong number of input arguments: %d expected.\n"), "load", 1));
978 if %__rhs__ >= 1 then
979 if typeof(%__filename__) <> "string" | size(%__filename__, "*") <> 1 then
980 error(999, msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"), "load", 1));
984 if isfile(%__filename__) & is_hdf5_file(%__filename__) then
985 %__loadFunction__ = import_from_hdf5;
986 //fileVersion = getScilabFileVersion(%__filename__); // Not needed for the moment
988 %__loadFunction__ = load;
991 //multiple output variables to prevent listinfile prints
992 [%__variableList__, %__varB__, %__varC__, %__varD__] = listvarinfile(%__filename__);
994 if size(varargin) <> 0 then
995 for i = 1:size(varargin)
996 %__variableName__ = varargin(i);
997 if typeof(%__variableName__) <> "string" | size(%__variableName__, "*") <> 1 then
998 error(999, msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"), "load", i));
1001 if or(%__variableList__ == %__variableName__) then
1002 %__loadFunction__(%__filename__, %__variableName__);
1003 %__resumeList__($+1) = evstr(%__variableName__);
1004 %__resumeVarlist__($+1) = %__variableName__;
1005 clear(%__variableName__);
1007 error(999, msprintf(gettext("%s: variable ''%s'' does not exist in ''%s''.\n"), "load", %__variableName__, %__filename__));
1011 for i = 1:size(%__variableList__, "*")
1012 %__variableName__ = %__variableList__(i);
1013 %__loadFunction__(%__filename__, %__variableName__);
1014 %__resumeList__($+1) = evstr(%__variableName__);
1015 %__resumeVarlist__($+1) = %__variableName__;
1016 clear(%__variableName__);
1020 if isfile(%__filename__) & is_hdf5_file(%__filename__) then
1021 %__resumeList__ = %__convertVariable__(%__resumeList__, %__resumeVarlist__);
1024 execstr("[" + strcat(%__resumeVarlist__, ",") + "] = resume(%__resumeList__(:))");