7d649f437b7cae47c857065b8ed4ffd29356d0c1
[scilab.git] / scilab / modules / io / macros / %_save.sci
1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 2012 - DIGITEO - Antoine ELIAS
3 // 
4 // This file must be used under the terms of the CeCILL.
5 // This source file is licensed as described in the file COPYING, which
6 // you should have received as part of this distribution.  The terms
7 // are also available at    
8 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
9
10 //2012/08/06 transform macros to string to save it
11
12 //called by save function, transform handle in tlist and save result
13 function [] = %_save(%__filename__, varargin)
14
15     function result = isList(var)
16
17         //15 : list
18         //16 : tlist
19         //17 : mlist
20         if or(type(var) == [15, 16, 17]) then
21             result  = %t;
22         else
23             result = %f;
24         end
25     endfunction
26
27     function result = isMacro(var)
28         //11 : sci_u_function
29         if or(type(var) == [11]) then
30             result  = %t;
31         else
32             result = %f;
33         end
34     endfunction
35
36     function result = isCompiledMacro(var)
37         //11 : sci_c_function
38         if or(type(var) == [13]) then
39             result  = %t;
40         else
41             result = %f;
42         end
43     endfunction
44
45     function result = inspectList(l)
46     if typeof(l)=="list" then
47         result = list();
48         for %__i__ = definedfields(l)
49             if typeof(l(%__i__)) == "handle" then
50                 result(%__i__) = extractMatrixHandle(l(%__i__));
51             elseif isList(l(%__i__)) then
52                 result(%__i__) = inspectList(l(%__i__));
53             else
54                 result(%__i__) = l(%__i__);
55             end
56         end
57     else
58         fieldNb = size(getfield(1, l), "*");
59         for kField = 2:fieldNb // Do not inspect first field (field names)
60             fieldValue = getfield(kField, l);
61             if typeof(fieldValue) == "handle" then
62                 fieldValue = extractMatrixHandle(fieldValue);
63             elseif isList(fieldValue) then
64                 fieldValue = inspectList(fieldValue);
65             end
66             setfield(kField, fieldValue, l);
67         end
68         result = l;
69     end
70     endfunction
71
72     function matrixHandle = extractMatrixHandle(h)
73
74         if typeof(h) <> "handle" then
75             matrixHandle = [];
76             return;
77         end
78
79         matrixHandle = tlist(["ScilabMatrixHandle", "dims", "values"]);
80         matrixHandle.dims = size(h);
81         matrixHandle.values = list();
82         for %__i__ = 1:size(h, "*")
83             matrixHandle.values($+1) = extractSingleHandle(h(%__i__));
84             if or(fieldnames(matrixHandle.values($))=="user_data") then // TODO Remove after graphic branch merge
85                 if isList(matrixHandle.values($).user_data) then
86                     matrixHandle.values($).user_data = inspectList(matrixHandle.values($).user_data)
87                 elseif typeof(matrixHandle.values($).user_data) == "handle" then
88                     matrixHandle.values($).user_data = extractMatrixHandle(matrixHandle.values($).user_data)
89                 end
90             end
91         end
92     endfunction
93
94
95     function item = extractSingleHandle(h)
96
97         select h.type
98         case "Figure"
99             item = extractFigure(h);
100         case "Axes"
101             item = extractAxes(h);
102         case "Polyline"
103             item = extractPolyline(h);
104         case "Plot3d"
105             item = extractPlot3d(h);
106         case "Fac3d"
107             item = extractFac3d(h);
108         case "Compound"
109             item = extractCompound(h);
110         case "Rectangle"
111             item = extractRectangle(h);
112         case "Arc"
113             item = extractArc(h);
114         case "Champ"
115             item = extractChamp(h);
116         case "Segs"
117             item = extractSegs(h);
118         case "Grayplot"
119             item = extractGrayplot(h);
120         case "Matplot"
121             item = extractMatplot(h);
122         case "Fec"
123             item = extractFec(h);
124         case "Legend"
125             item = extractLegend(h);
126         case "Text"
127             item = extractText(h);
128         case "Axis"
129             item = extractAxis(h);
130         case "uimenu"
131             item = extractuimenu(h);
132         case "uicontextmenu"
133             item = extractuicontextmenu(h);
134         case "uicontrol"
135             item = extractuicontrol(h);
136         else
137             error("handle of type " + h.type + " unhandled");
138             item = [];
139         end
140     endfunction
141
142     //
143     // FIGURE
144     //
145     function returnedFigure = extractFigure(h)
146         returnedFigure = tlist([
147                 "ScilabSingleHandle", ...
148                 "type", ...
149                 "visible", ...
150                 "figure_position", ...
151                 "figure_size", ...
152                 "axes_size", ...
153                 "viewport", ...
154                 "info_message", ...
155                 "tag", ...
156                 "auto_resize", ...
157                 "figure_name", ...
158                 "figure_id", ...
159                 "color_map", ...
160                 "pixmap", ...
161                 "pixel_drawing_mode", ...
162                 "anti_aliasing", ...
163                 "immediate_drawing", ...
164                 "background", ...
165                 "rotation_style", ...
166                 "event_handler", ...
167                 "event_handler_enable", ...
168                 "resizefcn", ...
169                 "closerequestfcn", ...
170                 "children", ...
171                 "user_data"]);
172             
173         fields = fieldnames(returnedFigure);
174
175         for %__i__ = 1:size(fields, "*")
176             if fields(%__i__) == "children" then
177                 returnedFigure(fields(%__i__)) = extractMatrixHandle(h(fields(%__i__)));
178             else
179                 returnedFigure(fields(%__i__)) = h(fields(%__i__));
180             end
181         end
182     endfunction
183
184     //
185     // LABEL
186     //
187     function returnedLabel = extractLabel(h)
188         returnedLabel = tlist([
189                     "ScilabSingleHandle", ...
190                     "type", ...
191                     "visible", ...
192                     "text", ...
193                     "font_foreground", ...
194                     "foreground", ...
195                     "background", ...
196                     "fill_mode", ...
197                     "font_style", ...
198                     "font_size", ...
199                     "fractional_font", ...
200                     "font_angle", ...
201                     "auto_rotation", ...
202                     "position", ...
203                     "auto_position"]);
204
205         fields = fieldnames(returnedLabel);
206
207         for %__i__ = 1:size(fields, "*")
208             returnedLabel(fields(%__i__)) = h(fields(%__i__));
209         end
210     endfunction
211
212     //
213     // TICKS
214     //
215     function returnedTicks = extractTicks(ticks)
216         returnedTicks = tlist([
217                     "Ticks", ...
218                     "locations", ...
219                     "labels"]);
220
221         fields = fieldnames(returnedTicks);
222
223         for %__i__ = 1:size(fields, "*")
224             returnedTicks(fields(%__i__)) = ticks(fields(%__i__));
225         end
226     endfunction
227
228     //
229     // AXES
230     //
231     function returnedAxes = extractAxes(h)
232         returnedAxes = tlist([
233                     "ScilabSingleHandle", ...
234                     "type", ...
235                     "visible", ...
236                     "axes_visible", ...
237                     "axes_reverse", ...
238                     "grid", ...
239                     "grid_position", ...
240                     "x_location", ...
241                     "y_location", ...
242                     "view", ...
243                     "title", ...
244                     "x_label", ...
245                     "y_label", ...
246                     "z_label", ...
247                     "auto_ticks", ...
248                     "x_ticks", ...
249                     "y_ticks", ...
250                     "z_ticks", ...
251                     "box", ...
252                     "filled", ...
253                     "sub_tics", ...
254                     "font_style", ...
255                     "font_size", ...
256                     "font_color", ...
257                     "fractional_font", ...
258                     "isoview", ...
259                     "cube_scaling", ...
260                     "rotation_angles", ...
261                     "log_flags", ...
262                     "tight_limits", ...
263                     "data_bounds", ...
264                     "zoom_box", ...
265                     "margins", ...
266                     "axes_bounds", ...
267                     "auto_clear", ...
268                     "auto_scale", ...
269                     "hidden_axis_color", ...
270                     "arc_drawing_method", ...
271                     "hiddencolor", ...
272                     "line_mode", ...
273                     "line_style", ...
274                     "thickness", ...
275                     "mark_mode", ...
276                     "mark_style", ...
277                     "mark_size", ...
278                     "mark_size_unit", ...
279                     "mark_foreground", ...
280                     "mark_background", ...
281                     "foreground", ...
282                     "background", ...
283                     "clip_state", ...
284                     "clip_box", ...
285                     "children", ...
286                     "user_data"]);
287
288         fields = fieldnames(returnedAxes);
289
290         for %__i__ = 1:size(fields, "*")
291             if or(fields(%__i__) == ["title","x_label","y_label","z_label"]) then
292                 returnedAxes(fields(%__i__)) = extractLabel(h(fields(%__i__)));
293             elseif or(fields(%__i__) == ["x_ticks", "y_ticks", "z_ticks"]) then
294                 returnedAxes(fields(%__i__)) = extractTicks(h(fields(%__i__)));
295             elseif fields(%__i__) == "children" then
296                 returnedAxes(fields(%__i__)) = extractMatrixHandle(h(fields(%__i__)));
297             else
298                 returnedAxes(fields(%__i__)) = h(fields(%__i__));
299             end
300         end
301     endfunction
302
303     //
304     // POLYLINE
305     //
306     function returnedPolyline = extractPolyline(h)
307         returnedPolyline = tlist([
308                 "ScilabSingleHandle", ...
309                 "type", ...
310                 "visible", ...
311                 "data", ...
312                 "closed", ...
313                 "line_mode", ...
314                 "fill_mode", ...
315                 "line_style", ...
316                 "thickness", ...
317                 "arrow_size_factor", ...
318                 "polyline_style", ...
319                 "interp_color_vector", ...
320                 "interp_color_mode", ...
321                 "mark_mode", ...
322                 "mark_style", ...
323                 "mark_size", ...
324                 "mark_size_unit", ...
325                 "foreground", ...
326                 "background", ...
327                 "mark_foreground", ...
328                 "mark_background", ...
329                 "x_shift", ...
330                 "y_shift", ...
331                 "z_shift", ...
332                 "bar_width", ...
333                 "clip_state", ...
334                 "clip_box", ...
335                 "user_data"]);
336
337         fields = fieldnames(returnedPolyline);
338
339         for %__i__ = 1:size(fields, "*")
340             returnedPolyline(fields(%__i__)) = h(fields(%__i__));
341         end
342     endfunction
343
344     //
345     // PLOT3D
346     //
347     function returnedPlot3d = extractPlot3d(h)
348         returnedPlot3d = extractSurface(h);
349     endfunction
350
351     //
352     // FAC3D
353     //
354     function returnedFac3d = extractFac3d(h)
355         returnedFac3d = extractSurface(h);
356     endfunction
357
358     //
359     // SURFACE
360     //
361     function returnedSurface = extractSurface(h)
362         returnedSurface = tlist([
363                 "ScilabSingleHandle", ...
364                 "type", ...
365                 "visible", ...
366                 "surface_mode", ...
367                 "foreground", ...
368                 "thickness", ...
369                 "mark_mode", ...
370                 "mark_style", ...
371                 "mark_size", ...
372                 "mark_size_unit", ...
373                 "mark_foreground", ...
374                 "mark_background", ...
375                 "color_mode", ...
376                 "color_flag", ...
377                 "data", ...
378                 "color_flag", ...
379                 "hiddencolor", ...
380                 "clip_state", ...
381                 "clip_box", ...
382                 "user_data", ...
383                 "cdata_mapping"]);
384
385         fields = fieldnames(returnedSurface);
386
387         for %__i__ = 1:size(fields, "*")
388             if fields(%__i__)=="cdata_mapping" then
389                 if h.type=="Fac3d" then
390                     returnedSurface(fields(%__i__)) = h(fields(%__i__));
391                 end
392             else
393                 returnedSurface(fields(%__i__)) = h(fields(%__i__));
394             end
395         end
396     endfunction
397
398     //
399     // COMPOUND
400     //
401     function returnedCompound = extractCompound(h)
402         returnedCompound = tlist([
403                 "ScilabSingleHandle", ...
404                 "type", ...
405                 "visible", ...
406                 "children", ...
407                 "user_data"]);
408
409         fields = fieldnames(returnedCompound);
410
411         for %__i__ = 1:size(fields, "*")
412             if fields(%__i__) == "children" then
413                 returnedCompound(fields(%__i__)) = extractMatrixHandle(h(fields(%__i__)));
414             else
415                 returnedCompound(fields(%__i__)) = h(fields(%__i__));
416             end
417         end
418     endfunction
419
420     //
421     // RECTANGLE
422     //
423     function returnedRectangle = extractRectangle(h)
424         returnedRectangle = tlist([
425                 "ScilabSingleHandle", ...
426                 "type", ...
427                 "visible", ...
428                 "thickness", ...
429                 "mark_mode", ...
430                 "mark_style", ...
431                 "mark_size", ...
432                 "mark_size_unit", ...
433                 "mark_foreground", ...
434                 "mark_background", ...
435                 "line_mode", ...
436                 "line_style", ...
437                 "fill_mode", ...
438                 "foreground", ...
439                 "background", ...
440                 "data", ...
441                 "clip_state", ...
442                 "clip_box", ...
443                 "user_data"]);
444
445         fields = fieldnames(returnedRectangle);
446
447         for %__i__ = 1:size(fields, "*")
448             returnedRectangle(fields(%__i__)) = h(fields(%__i__));
449         end
450     endfunction
451
452     //
453     // ARC
454     //
455     function returnedArc = extractArc(h)
456         returnedArc = tlist([
457                 "ScilabSingleHandle", ...
458                 "type", ...
459                 "visible", ...
460                 "thickness", ...
461                 "line_style", ...
462                 "line_mode", ...
463                 "fill_mode", ...
464                 "foreground", ...
465                 "background", ...
466                 "data", ...
467                 "arc_drawing_method", ...
468                 "clip_state", ...
469                 "clip_box", ...
470                 "user_data"]);
471
472         fields = fieldnames(returnedArc);
473
474         for %__i__ = 1:size(fields, "*")
475             returnedArc(fields(%__i__)) = h(fields(%__i__));
476         end
477     endfunction
478
479     //
480     // CHAMP
481     //
482     function returnedChamp = extractChamp(h)
483          returnedChamp = tlist([
484                 "ScilabSingleHandle", ...
485                 "type", ...
486                 "visible", ...
487                 "data", ...
488                 "line_style", ...
489                 "thickness", ...
490                 "colored", ...
491                 "arrow_size", ...
492                 "clip_state", ...
493                 "clip_box", ...
494                 "user_data"]);
495
496         fields = fieldnames(returnedChamp);
497
498         for %__i__ = 1:size(fields, "*")
499             returnedChamp(fields(%__i__)) = h(fields(%__i__));
500         end
501     endfunction
502
503     //
504     // SEG
505     //
506     function returnedSeg = extractSegs(h)
507         returnedSeg = tlist([
508                 "ScilabSingleHandle", ...
509                 "type", ...
510                 "visible", ...
511                 "data", ...
512                 "line_mode", ...
513                 "line_style", ...
514                 "thickness", ...
515                 "segs_color", ...
516                 "mark_mode", ...
517                 "mark_style", ...
518                 "mark_size", ...
519                 "mark_size_unit", ...
520                 "mark_foreground", ...
521                 "mark_background", ...
522                 "clip_state", ...
523                 "clip_box", ...
524                 "user_data"]);
525
526         fields = fieldnames(returnedSeg);
527
528         for %__i__ = 1:size(fields, "*")
529             returnedSeg(fields(%__i__)) = h(fields(%__i__));
530         end
531     endfunction
532
533     //
534     // GRAYPLOT
535     //
536     function returnedGrayplot = extractGrayplot(h)
537         returnedGrayplot = tlist([
538                 "ScilabSingleHandle", ...
539                 "type", ...
540                 "visible", ...
541                 "data", ...
542                 "data_mapping", ...
543                 "clip_state", ...
544                 "clip_box", ...
545                 "user_data"]);
546
547         fields = fieldnames(returnedGrayplot);
548
549         for %__i__ = 1:size(fields, "*")
550             returnedGrayplot(fields(%__i__)) = h(fields(%__i__));
551         end
552     endfunction
553
554     //
555     // MATPLOT
556     //
557     function returnedMatplot = extractMatplot(h)
558         returnedMatplot = tlist([
559                 "ScilabSingleHandle", ...
560                 "type", ...
561                 "visible", ...
562                 "data", ...
563                 "clip_state", ...
564                 "clip_box", ...
565                 "user_data"]);
566
567         fields = fieldnames(returnedMatplot);
568
569         for %__i__ = 1:size(fields, "*")
570             returnedMatplot(fields(%__i__)) = h(fields(%__i__));
571         end
572     endfunction
573
574     //
575     // FEC
576     //
577     function returnedFec = extractFec(h)
578         returnedFec = tlist([
579                 "ScilabSingleHandle", ...
580                 "type", ...
581                 "visible", ...
582                 "data", ...
583                 "triangles", ...
584                 "z_bounds", ...
585                 "color_range", ...
586                 "outside_colors", ...
587                 "line_mode", ...
588                 "foreground", ...
589                 "clip_state", ...
590                 "clip_box", ...
591                 "user_data"]);
592
593         fields = fieldnames(returnedFec);
594
595         for %__i__ = 1:size(fields, "*")
596             returnedFec(fields(%__i__)) = h(fields(%__i__));
597         end
598     endfunction
599
600     //
601     // LEGEND
602     //
603     function returnedLegend = extractLegend(h)
604         returnedLegend = tlist([
605                 "ScilabSingleHandle", ...
606                 "type", ...
607                 "visible", ...
608                 "text", ...
609                 "font_style", ...
610                 "font_size", ...
611                 "font_color", ...
612                 "fractional_font", ...
613                 "links", ...
614                 "legend_location", ...
615                 "position", ...
616                 "line_mode", ...
617                 "thickness", ...
618                 "foreground", ...
619                 "fill_mode", ...
620                 "background", ...
621                 "clip_state", ...
622                 "clip_box", ...
623                 "user_data", ..
624                 "paths"]);
625
626         fields = fieldnames(returnedLegend);
627
628         for %__i__ = 1:size(fields, "*")
629             if fields(%__i__) == "links" then
630                 returnedLegend(fields(%__i__)) = extractMatrixHandle(h(fields(%__i__)));
631             elseif fields(%__i__) == "paths" then
632                 p = list();
633                 for kl=1:size(h.links,'*');
634                     p($+1) = get_entity_path(h.links(kl));
635                 end
636                 returnedLegend(fields(%__i__)) = p;
637             else
638                 returnedLegend(fields(%__i__)) = h(fields(%__i__));
639             end
640         end
641     endfunction
642
643     //
644     // TEXT
645     //
646     function returnedText = extractText(h)
647         returnedText = tlist([
648                 "ScilabSingleHandle", ...
649                 "type", ...
650                 "visible", ...
651                 "text", ...
652                 "data", ...
653                 "text_box", ...
654                 "text_box_mode", ...
655                 "foreground", ...
656                 "font_style", ...
657                 "font_size", ...
658                 "font_angle", ...
659                 "box", ...
660                 "line_mode", ...
661                 "fill_mode", ...
662                 "font_foreground", ...
663                 "background", ...
664                 "alignment", ...
665                 "fractional_font", ...
666                 "clip_state", ...
667                 "clip_box", ...
668                 "user_data"]);
669
670         fields = fieldnames(returnedText);
671
672         for %__i__ = 1:size(fields, "*")
673             returnedText(fields(%__i__)) = h(fields(%__i__));
674         end
675     endfunction
676
677     //
678     // AXIS
679     //
680     function returnedAxis = extractAxis(h)
681         returnedAxis = tlist([
682                 "ScilabSingleHandle", ...
683                 "type", ...
684                 "visible", ...
685                 "tics_direction", ...
686                 "xtics_coord", ...
687                 "ytics_coord", ...
688                 "tics_color", ...
689                 "tics_segment", ...
690                 "tics_style", ...
691                 "sub_tics", ...
692                 "tics_labels", ...
693                 "labels_font_size", ...
694                 "labels_font_color", ...
695                 "fractional_font", ...
696                 "clip_state", ...
697                 "clip_box", ...
698                 "user_data"]);
699
700         fields = fieldnames(returnedAxis);
701
702         for %__i__ = 1:size(fields, "*")
703             returnedAxis(fields(%__i__)) = h(fields(%__i__));
704         end
705     endfunction
706
707     //
708     // uimenu
709     //
710     function returneduimenu = extractuimenu(h)
711         returneduimenu = tlist([
712                 "ScilabSingleHandle", ...
713                 "type", ...
714                 "enable", ...
715                 "foregroundcolor", ...
716                 "label", ...
717                 "visible", ...
718                 "callback", ...
719                 "callback_type", ...
720                 "tag", ...
721                 "checked", ...
722                 "children", ..
723                 "user_data"]);
724
725         fields = fieldnames(returneduimenu);
726
727         for %__i__ = 1:size(fields, "*")
728             if fields(%__i__) == "children" then
729                 returneduimenu(fields(%__i__)) = extractMatrixHandle(h(fields(%__i__))($:-1:1));
730             else
731                 returneduimenu(fields(%__i__)) = h(fields(%__i__));
732             end
733         end
734     endfunction
735
736     //
737     // UICONTEXTMENU
738     //
739     function returneduicontextmenu = extractuicontextmenu(h)
740         returneduicontextmenu = tlist([
741                 "ScilabSingleHandle", ...
742                 "type", ...
743                 "children"]);
744
745         fields = fieldnames(returneduicontextmenu);
746
747         for %__i__ = 1:size(fields, "*")
748             if fields(%__i__) == "children" then
749                 returneduicontextmenu(fields(%__i__)) = extractMatrixHandle(h(fields(%__i__))($:-1:1));
750             else
751                 returneduicontextmenu(fields(%__i__)) = h(fields(%__i__));
752             end
753         end
754     endfunction
755
756     //
757     // uicontrol
758     //
759     function returneduicontrol = extractuicontrol(h)
760         returneduicontrol = tlist([
761                 "ScilabSingleHandle", ...
762                 "type", ...
763                 "style", ...
764                 "backgroundcolor", ...
765                 "enable", ...
766                 "fontangle", ...
767                 "fontname", ...
768                 "fontsize", ...
769                 "fontunits", ...
770                 "fontweight", ...
771                 "foregroundcolor", ...
772                 "horizontalalignment", ...
773                 "listboxtop", ...
774                 "max", ...
775                 "min", ...
776                 "position", ...
777                 "relief", ...
778                 "sliderstep", ...
779                 "string", ...
780                 "tooltipstring", ...
781                 "units", ...
782                 "value", ...
783                 "verticalalignment", ...
784                 "visible", ...
785                 "callback", ...
786                 "callback_type", ...
787                 "user_data", ...
788                 "tag", ...
789                 "children"]);
790
791         fields = fieldnames(returneduicontrol);
792
793         for %__i__ = 1:size(fields, "*")
794             if fields(%__i__) == "children" then
795                 returneduicontrol(fields(%__i__)) = extractMatrixHandle(h(fields(%__i__))($:-1:1));
796             else
797                 returneduicontrol(fields(%__i__)) = h(fields(%__i__));
798             end
799         end
800     endfunction
801
802     // Utility function for legends, copy/paste from %h_load
803     function p=get_entity_path(e)
804     // given a handle e on an entity this function returns its path relative
805     // to its parent axes.
806     // the path is a vector of child index.
807     p=[];
808     parent=e.parent;
809
810     while  %t
811         pos=find(parent.children==e,1)
812         if pos==[] then
813             error(msprintf(_("%s : Invalid entity %s\n"),"save","Legend"))
814         end
815         p=[pos p]
816         if parent.type=='Axes' then
817             break
818         end
819         e=parent
820         parent=e.parent;
821     end
822     endfunction
823
824     function macro = extractMacro(macroPtr, macroName)
825         macroSt = fun2string(macroPtr, macroName);
826         oldMode = warning("query");
827         warning("off");
828         macro = tlist("ScilabMacro", isCompiledMacro(macroPtr), macroSt);
829         warning(oldMode);
830     endfunction
831
832     //main
833
834     //save environment
835     if size(varargin) == 0 then
836         %__excludeList__ = [
837             "%_save"
838             "isList"
839             "isMacro"
840             "isCompiledMacro"
841             "inspectList"
842             "extractMatrixHandle"
843             "extractSingleHandle"
844             "extractFigure"
845             "extractLabel"
846             "extractTicks"
847             "extractAxes"
848             "extractPolyline"
849             "extractPlot3d"
850             "extractFac3d"
851             "extractSurface"
852             "extractCompound"
853             "extractRectangle"
854             "extractArc"
855             "extractChamp"
856             "extractSegs"
857             "extractGrayplot"
858             "extractMatplot"
859             "extractFec"
860             "extractLegend"
861             "extractText"
862             "extractAxis"
863             "extractuimenu"
864             "extractuicontextmenu"
865             "extractuicontrol"
866             "get_entity_path"
867             "extractMacro"
868             "%__excludeList__"
869             "%__filename__"
870             "varargin"
871             "%__varList__"];
872
873         //get all user variables
874         %__varList__ = who_user(%f);
875         //remove exclude variables/functions
876         %__grepResult__ = grep(%__varList__, %__excludeList__);
877         %__varList__(%__grepResult__) = [];
878         for %__i__ = 1:size(%__varList__, "*")
879             //store them as input arguments
880             varargin(%__i__) = %__varList__(%__i__);
881         end
882     end
883
884     oldMode = warning("query");
885     warning("off");
886
887     if size(varargin) == 0 then
888     end
889
890     for %__i__ = 1:size(varargin)
891
892         if varargin(%__i__) == "-append" then
893             continue;
894         end
895
896         temp = evstr(varargin(%__i__));
897
898         if isList(temp) then
899             //list container
900             value = inspectList(temp);
901             //update 
902             execstr(varargin(%__i__) + " = value");
903         elseif typeof(temp) == "handle" then
904             //convert handle to tlist
905             value = extractMatrixHandle(temp);
906             //update 
907             execstr(varargin(%__i__) + " = value");
908         elseif isMacro(temp) | isCompiledMacro(temp) then
909             //convert macro to tlist
910             value = extractMacro(temp, varargin(%__i__));
911             //update 
912             execstr(varargin(%__i__) + " = value");
913         end
914     end
915     warning(oldMode);
916
917     result = export_to_hdf5(%__filename__, varargin(:));
918
919 endfunction