function [iSuccess, stErrorMsg] = readFile(fullFile)
% readFile 
%   readFile reads file

%   Project: IMPACT
%   Title of Code: readFile
%   Relevant additional documentation:
%   Developer: Carlos Gonzalez
%   External Dependencies: NA
%
%   Disclaimer
%   CAUTION: It is strongly recommended that changes to this code
%   should be avoided without first consulting with authors.

fid = fopen(fullFile);
if fid == -1
    stErrorMsg = sprintf('File %s cannot be open for reading', fullFile);
    iSuccess = -1;
    return;
end
m = 1;
while 1
    stLine = fgetl(fid);
    if ~ischar(stLine)
        break
    end
    try
        eval(stLine);
    catch
        stErrorMsg = sprintf('Error occurred when reading line %d: %s. ', m, stLine);
        iSuccess = -1;
        fclose(fid);
        return
    end
    m = m+1;
end
fclose(fid);
clear fid m stLine
zVars = whos;

for iCont=1:numel(zVars)
    assignin('caller',zVars(iCont).name,eval(zVars(iCont).name));
end

iSuccess = 1;
stErrorMsg = '';