function val = input(prompt, strflag)
% INPUT Read (and EVAL) input.
% This function replaces MATLAB's regular INPUT statement in compiled
% applications.

% Copyright 2004-2014 The MathWorks, Inc.

    narginchk(0, 2)
    if nargin == 2
        if strflag == 's'
            val = readline(prompt);
            val = regexprep(val,'\r\n|\n|\r','');
        else
            error(message('MCR:INPUT:BadInput'));
        end
    else
      if nargin == 0
          prompt = '';
      end

      while true
        try
          str = readline(prompt);
          str = regexprep(str,'\r\n|\n|\r','');
          if isempty(str)
            val = str;
          else              
            val = evalin('caller', str);
          end
          break; 
        catch ex
          disp(ex.message);
        end
      end
    end
