Scilab Function
eng


generate_dem_scicos

File content


//fonction qui genère le texte du fichier
//demo concernant les diagrammes scicos
//rmq : n'est pas stocké dans un fichier
//
//g le numéro dans la liste
//listt : la matrice de chaine de caratère de la liste
//        (diagr_list ou sim_list)
function txt=generate_dem_scicos(g,listt)
    if ~exists('xml_path') then 
       //retrieve default LANGUAGE
       if ~exists('LANGUAGE') then
          global LANGUAGE;lang=LANGUAGE;clear LANGUAGE;
       else
          lang=LANGUAGE;
       end
       if lang<>'eng' & lang<>'fr' then
         printf("language %s is not supported, switch to ''eng''\n",lang);
         lang='eng'
       end
       xml_path=MODNUM+'/man/'+lang+'/xml/'; 
    end

    if listt==[]|listt=="" then txt=[]; return, end;
    if g==0|g>size(listt,1) then txt=[]; return, end; 
    ierror=execstr('myvar=evstr(listt(g,1))','errcatch');
    if ierror<>0 then txt=[]; return, end;
    if myvar==[] then txt=[]; return, end;
 
    demos_name=[];
    path_demos=[];
    tt=[];
    tt1=[];
    tt2=[];
    if lang=='fr' then
       tt_title='Choisissez une démo'
    else
       tt_title='Choose a demo'
    end
    for i=1:size(myvar,1)
       demos_name(i)=ret_xml_sdesc(xml_path+myvar(i,2)+'_diagr.xml');
       stri=strindex(myvar(i,1),MODNUM);
       path_demos(i)=myvar(i,1);
       tt1=[tt1;''''+strsubst(demos_name(i),'''','''''')+''''];
       tt2=[tt2;'case '''+strsubst(demos_name(i),'''','''''')+''' then';
            '  scicos('''+path_demos(i)+myvar(i,2)+'.cos'');'];
    end
    tt1(size(tt1,1))=tt1(size(tt1,1))+']';
    tt1=['mode(-1)';'demos_name=[';tt1];
    tt2=['if ~exists(''fun'') then'
         '  fun=x_choose'
         '  if exists(''with_tk'') then'
         '    if whereis(''tk_choose'')<>[] then'
         '      if with_tk() then fun=tk_choose, end;'
         '    end'
         '  end'
         'end'
         'while %t do'
         'n=fun(demos_name,'''+tt_title+''')'
         'if n ==0 then break,end'
         'select demos_name(n)'
         tt2
         'end';'end'];
    tt=[tt1;tt2];
    txt=tt;
endfunction