generate_dem_sim - generate text of scilab simulation script demonstrations of the toolbox
txt = generate_dem_sim(g,listt)
- g : integer. id of the scimulation script
- listt : matrix of strings. ('diagr_list' or 'sim_list')
- txt : vector of strings. text of the demo to execute
//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)
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/xml/'+lang+'/';
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)=return_xml_sdesc(xml_path+myvar(i,2)+'.xml');
stri=strindex(myvar(i,1),MODNUM);
//if stri<>[] then
// path_demos(i)='MODNUM+'+''''+part(myvar(i,1),stri+length(MODNUM):length(myvar(i,1)));
//end
path_demos(i)=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 with_tk() then fun=tk_choose, 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
IRCOM Group
Alan Layec