interactive button or menu definition
addmenu(button [,submenus] [,action])
addmenu(gwin,button [,submenus] [,action])
: :submenus a vector of character string. The sub_menus items names : :action a list with 2 elements action=list(flag,proc_name)
:flag an integer (default value is 0) : :flag==0 the action is defined by a scilab instruction : :flag==1 the action is defined by a C or Fortran procedure : :flag==2 the action is defined by a scilab function : :proc_name a character string which gives the name of scilab
variable containing the instruction or the name of procedure to call.:
:
The function allows the user to add new buttons or menus in the main window or graphics windows command panels.
:
if (`getscilabmode`_() == "STD") then
addmenu('foo');
foo = 'disp(''hello'')';
addmenu('Hello',['Franck';'Peter'])
Hello = ['disp(''hello Franck'')';'disp(''hello Peter'')'];
addmenu('Bye',`list`_(0,'French_Bye'));
French_Bye = 'disp(''Au revoir'')';
else
`mprintf`_('This example requires to use scilab with GUI mode.\n');
end
addmenu(0,'Hello',['Franck';'Peter']);
Hello_0 = ['disp(''hello Franck'')';'disp(''hello Peter'')'];
//C defined Callback
// creating Callback code
code=[ '#include ""machine.h""'
'#include ""sciprint.h""'
'void foo(char *name, int *win, int *entry)'
'{'
' if (*win==-1) '
' sciprint(""menu %s(%i) in Scilab window selected.\n"", name, *entry+1);'
' else'
' sciprint(""menu %s(%i) in window %i selected.\n"", name, *entry+1, *win);'
'}'];
//creating foo.c file
current_dir = pwd();
`chdir`_(TMPDIR);
`mputl`_(code, TMPDIR+'/foo.c');
//creating Makefile
`ilib_for_link`_('foo','foo.c',[],'c');
`exec`_('loader.sce');
`chdir`_(current_dir);
//add menu
addmenu(0,'foo',['a','b','c'],`list`_(1,'foo'));