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