function idemo(fname)
% idemo(fname) -- in-class demonstration function to execute
%                 M codes line by line.
% Last modified 2023 August by Motoya Machida
% --Boolean operator (|) was changed to (||).

     fid = fopen(fname, 'r');
     fprintf('Execute \"%s\" in idemo.\n\n', fname);

     code = fgetl(fid);
     while (feof(fid) == 0 || length(code) > 1)
       if (length(code) == 0)
         fprintf('\n');
       elseif (findstr(code,'%') == 1)
         fprintf('%s\n', code);
       else
         fprintf('> ');
         disp(code);
         input('');
         eval(code);
         fprintf('\n');
       end
       code = fgetl(fid);
     end

     fclose(fid);
     input('> exit');


