IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 17, 2014, 10:21:10 AM (12 years ago)
Author:
eugene
Message:

various changes due to mods to average.d and measure.d; new parsing concept for photocode-related fields

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/lib.shell/string.c

    r33662 r37049  
    322322}
    323323
     324int set_list_varname (char *line, char *base, int N, int excelStyle) {
     325
     326  int i;
     327   
     328  // A-Z correspond to 0 - 25
     329
     330  if (excelStyle) {
     331    float f = log(26.0);
     332    float g = (N == 0) ? 0.0 : log(1.0*N);
     333    int Ndigit = (int) (g / f) + 1;
     334    if (Ndigit > 10) {
     335      sprintf (line, "%s:ZZZZZZZZZZ", base);
     336      return FALSE;
     337    }
     338    char name[12];
     339    memset (name, 0, 12);
     340    for (i = 0; i < Ndigit; i++) {
     341      float Npow = Ndigit - i - 1;
     342      float g = pow(26.0, Npow);
     343      int V = (int) (N / g);
     344      name[i] = (Npow == 0.0) ? 'A' + V : 'A' + V - 1;
     345      N -= V * g;
     346    }
     347    sprintf (line, "%s:%s", base, name);
     348  } else {
     349    sprintf (line, "%s:%d", base, N);
     350  }
     351  return TRUE;
     352}
Note: See TracChangeset for help on using the changeset viewer.