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

% Copyright 2004-2017 The MathWorks, Inc.

narginchk(0,2)

if nargin == 0
    prompt = '';
end

prompt = convertStringsToChars(prompt);

if nargin == 2
    if strcmp(strflag,'s')
        val = readline(prompt);
        val = regexprep(val,'\r\n|\n|\r','');
    else
        error(message('MCR:INPUT:BadInput'))
    end
else
    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
