function [TimeBL,ADCBaro,tempBaro,ErrBaroLink] = defDatiBL(DatiBaroLink,ErrBaroLink,rBL,FileName)

fileID = fopen(FileName,'a');
fmt = '%s \r';
text = 'defDatiBL function started';
fprintf(fileID,fmt,text);

[r,c]=size(DatiBaroLink);
Ncorr = 0;
% Elimino gli eventuali Not a Number
for a = 2:r
    for b = 1:c
        check = isnan(DatiBaroLink(a,b));
        if check == 1
            DatiBaroLink(a,b) = DatiBaroLink(a-1,b);
            ErrBaroLink(a,b-1) = 1;
            Ncorr = Ncorr+1;
        end
    end
end

text = [num2str(Ncorr) ' NaN of Baro Link corrected by defDatiBL function'];
fprintf(fileID,fmt,text);

% Definisco Data (gg:mm:aaaa hh:mm)ed i 2 dati 
% per il piezometro 
[r,c] = size(DatiBaroLink);
TimeBL = DatiBaroLink(:,1); % data

ADCBaro = zeros(r,rBL);
tempBaro = zeros(r,rBL);
s = 1;
b = 2; % colonna del primo piezometro
while b <= c      
      ADCBaro(:,s) = DatiBaroLink(:,b); % dati ADC barometro
      tempBaro(:,s) = DatiBaroLink(:,b+1); % dati ADC barometro
      b = b+2;
      s = s+1;
end

text = 'Data of Baro Link defined correctly. defDatiBL function ended';
fprintf(fileID,fmt,text);
fclose(fileID);

end