Back to index

texmacs  1.0.7.15
struct2tree.m
Go to the documentation of this file.
00001 ## Released under the GNU General Public License, see www.gnu.org
00002 ## Copyright (C) 2002 by the Free Software Foundation
00003 ## Written by Michael Graffam mikegraffam@yahoo.com
00004 ##
00005 ## Convert an Octave structure to a Scheme tree
00006 ## Created: Sept 2002
00007 
00008 function tmp=struct2tree(n,name)
00009 
00010        global TMCOLORS;
00011        global TMCOLIDX;
00012 
00013        # Make sure name is defined 
00014        if ((nargin<2))
00015               name="(with \"mode\" \"math\" (big \"triangleup\"))";
00016        endif
00017 
00018        keycolor=deblank(TMCOLORS(1,:));
00019        valcolor=deblank(TMCOLORS(TMCOLIDX,:));
00020 
00021        tmp=["(tree (with \"color\" \"", keycolor, "\" ",name,") "];
00022        for [val, key] = n
00023               switch (typeinfo(val))
00024                      case ("struct")
00025                             ## Itemize the new struct, and switch the key color
00026                             tmp1=struct2tree(val,key);
00027                      otherwise
00028                             tmp1=["(switch (document (with \"color\" \"", keycolor,"\" \"",key,"\")) (tuple (tmarker) (with \"color\" \"", valcolor, "\" " ,obj2scm(val),"))) "];
00029               endswitch
00030               tmp=[tmp,tmp1];
00031        endfor
00032        tmp=[tmp,")"];
00033 endfunction