# include "addstar.h"

int replace_match (Average *average, Measure *measure, Stars *star) {

  int i, j, m;

  // index to first measure for this object
  m = average[0].measureOffset;  

  /* search for entry and replace values M, dM, R, D */
  for (i = 0; i < average[0].Nmeasure; i++) {
    j = i + m;
    if (measure[j].photcode != star[0].measure.photcode) continue;
    measure[j].dR = 3600.0*(average[0].R - star[0].average.R);
    measure[j].dD = 3600.0*(average[0].D - star[0].average.D);
    measure[j].M  = star[0].measure.M;
    measure[j].dM = star[0].measure.dM;
    star[0].found = average[0].measureOffset + i;
    return (TRUE);
  }
  return (FALSE);
}
