Fonction Scilab
fr


generate_dem_sim

Contenu du fichier


//fonction qui genère le texte du fichier
//demo concernant les scripts de simulation
//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_sim(g,listt,path)

     //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=path+'/help/'+lang+'/xml/';

    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)+'.xml');
       stri=strindex(myvar(i,1),path);
       //if stri<>[] then
       //  path_demos(i)='MODNUMSCI+'+''''+part(myvar(i,1),stri+length(MODNUMSCI):length(myvar(i,1)));
       //end
       path_demos(i)=strsubst(myvar(i,1),'''','''''');
       tt1=[tt1;''''+strsubst(demos_name(i),'''','''''')+''''];
       tt2=[tt2;'case '''+strsubst(demos_name(i),'''','''''')+''' then';
            '  scipad('''+path_demos(i)+myvar(i,2)+'/'+myvar(i,2)+'.sce'');'];
    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