function DatiElabAnalogLink = LastElab_bisAL(conn,NodoAnalogLink,rAL,...
    datainiAL,tempoiniAL,IDcentralina,DTcatena,FileName)

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

NAnalogLink = cell2mat(NodoAnalogLink(:,2)); 
NodeType = 'Analog Link';
ii = 1; % contatore
col = 8; % contatore colonne
while ii <= rAL
      ini_col = col-7;
     nN = num2str(NAnalogLink(ii,1));
     % Scarico di dati di spostamenti
     comando = ['select EventDate, EventTime, XShift, YShift, ZShift, X, Y, Z from ElabDataView where EventDate = ''' ...
         datainiAL ''' and EventTime >= ''' tempoiniAL ''' and  UnitName = ''' IDcentralina ''' and ToolNameID = '''...
         DTcatena ''' and NodeType = ''' NodeType ''' and NodeNum = ''' nN ''' '];
     curs = exec(conn,comando);
     curs = fetch(curs);
     DATnodoALd = curs.Data;  
     % Scarico di dati di spostamenti
     comando = ['select EventDate, EventTime, XShift, YShift, ZShift, X, Y, Z from ElabDataView where EventDate > ''' ...
         datainiAL ''' and  UnitName = ''' IDcentralina ''' and ToolNameID = '''...
         DTcatena ''' and NodeType = ''' NodeType ''' and NodeNum = ''' nN ''' '];
     curs = exec(conn,comando);
     curs = fetch(curs);
     DATnodoAL = curs.Data;  
     [~,c1] = size(DATnodoAL);
     [~,c2] = size(DATnodoALd);
     if c1 == c2
         DATnodoAL = [DATnodoALd; DATnodoAL];
     elseif c1 < c2 % solo giorno di riferimento
         DATnodoAL = DATnodoALd;
     end
     DatiElabAnalogLink(:,ini_col:col) = DATnodoAL(:,:);              
     col = col+8;
     ii = ii+1;
end

text = 'LastElab_bisAL function worked correctly for Analog Link';
fprintf(fileID,fmt,text);
fclose(fileID);
end