function varargout = create_main_inputfile(GID)
fid = fopen('main_inputfile.m','w+'); % open file
fprintf(fid, ...
['function varargout = main_inputfile(varargin)\n' ...
'%% Task(menu).name - name of task. Task(1).name is ''File'', Task(2).name is\n' ...
'%% ''Model'', Task(8).name is ''Help''.\n' ...
'%% Task(menu).string - For each menu item (or any sub-items), there are 4\n' ...
'%% parameters that needed to be specified.\n' ...
'%% (1) index -- There are up to 3 cascading levels of\n' ...
'%% menu items. Each level can have up to 9 menu items.\n' ...
'%% For example, "100" represents menu item 1 of level 1.\n' ...
'%% "236" is item 2 selected from level 1 and item 3 from\n' ...
'%% level 2 and item 6 from level 3.\n' ...
'%% (2) label -- menu item label corresponding to index\n' ...
'%% (3) type -- menu item type; type ''doc1'' if the\n' ...
'%% action is to open html or pdf file; ''run1'' to execute\n' ...
'%% a matlab function; etc.\n' ...
'%% (4) operands -- for type ''doc1'', this would be the\n' ...
'%% html or pdf file; for type ''run1'', this would be the\n' ...
'%% name of the function and its arguments.\n' ...
'%% You can enter the menu items in any order\n' ...
]);
fprintf(fid, ...
['clear all\n' ...
'if nargin > 0\n' ...
'%% update gui4gui_inputfile with modified "Task" from the gui4gui input GUI\n' ...
' GID = varargin{1};\n' ...
' %% insert any additional modifications here\n' ...
' save gui4gui_inputfile GID;\n' ...
'else\n' ...
'%% the gui4gui package comes with this mfile pre-loaded with the setup\n' ...
'%% for the MODE code. Some of these data are universal for all codes if\n' ...
'%% you prepare PDF/HTML files and label them with the same names, such as\n' ...
'%% to call the tutorial file Tutorial.ppt or name the abstract Abstract.pdf.\n' ...
'%% You may also edit this file and change any contents that you wish.\n' ...
'%% However, you should not remove any fields in Task. If you don''t need\n' ...
'%% a specific menu item, just remove its content, like this\n' ...
'%% Task(1).label = {};\n' ...
'%%\n' ...
'%% Define number of menus (File, Model, Articles, Tutorial, Examples, Run, Code, Help)\n' ...
'%%\n']);
fprintf(fid,'Nmenus = %d;\n',GID.Nmenus);
fprintf(fid,'\n');
Nmenus = GID.Nmenus;
for menu=1:Nmenus
fprintf(fid, ...
'Task(%d).name = ''%s'';\n', menu,GID.task(menu).name);
fprintf(fid, ...
'Task(%d).string = { ...\n',menu);
n = length(GID.task(menu).string(:,1));
for k=1:n
fprintf(fid,' %d ''%s'' ''%s'' ''%s'' ...\n',GID.task(menu).string{k,1:4});
end
fprintf(fid,'};\n\n');
end
fprintf(fid, ...
['for menu=1:Nmenus\n' ...
' task(menu).name = Task(menu).name;\n' ...
' for n=1:length(Task(menu).string(:))/4\n' ...
' task(menu).string(n,1) = Task(menu).string(1+(n-1)*4);\n' ...
' task(menu).string(n,2) = Task(menu).string(2+(n-1)*4);\n' ...
' task(menu).string(n,3) = Task(menu).string(3+(n-1)*4);\n' ...
' task(menu).string(n,4) = Task(menu).string(4+(n-1)*4);\n' ...
' end\n' ...
'end\n']);
fprintf(fid, ...
[' GID.guiName = ''%s'';\n' ...
' GID.Nmenus = Nmenus;\n' ...
' GID.frontImage = ''%s'';\n' ...
' GID.bgcolor = ''%s'';\n' ...
' GID.fontsize = %d;\n' ...
' GID.fontweight = ''%s'';\n' ...
' GID.position = [%4.2f %4.2f %4.2f %4.2f];\n' ...
' GID.resize = ''%s'';\n' ...
' GID.task = task;\n'], ...
GID.guiName, GID.frontImage, GID.bgcolor, GID.fontsize, ...
GID.fontweight, GID.position, GID.resize);
fprintf(fid,'\n');
fprintf(fid, ...
['%% The buildMainGUI builder needs fields label, type and ops\n' ...
'%% The addLabel function can extract them from GID''s string field\n' ...
' GID = addLabel(GID);\n']);
fprintf(fid,'\n');
fprintf(fid, ...
['%% returns the final GID to the caller.\n' ...
' varargout{1} = GID;\n' ...
'%% Also save GID to the following file.\n' ...
' save main_inputfile GID;\n' ...
'end %% if\n']);