// // Get next run number. // #include #include void main (int argc, char *argv[]) { int n; int NextSequence (void); n = NextSequence(); printf("set RUN=run%d\n", n); fprintf(stderr, "RUN=run%d\n", n); } // // Get next run sequence number. This is found in the file \run.txt, // which is created if not yet present. // int NextSequence (void) { FILE *f; char *Path = "\\run.txt"; long Value; f = fopen(Path, "r"); if (f == NULL) { Value = 1; } else { fscanf(f, "%ld", &Value); fclose(f); } f = fopen(Path, "w"); fprintf(f, "%ld", Value + 1); fclose(f); return Value; }