/* ************************************************************** */ /* * Module RUNPARAM * This module contains utility functions which get run parameter information. * * Zachary Wolf * 11/18/99 */ /* ************************************************************* */ /* INCLUDE FILES */ #include #include #include #include "runparam.h" #include "runparamui.h" /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONS */ void runparam_error(char* message); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * runparam_get_run_param * This function opens a window and gets the run parameters from * the user. * * Output: * run_param, structure containing the run parameters * * Zachary Wolf * 11/19/99 */ void runparam_get_run_param(struct run_param_struct* run_param) { /* Get the run parameters from the user */ runparamui_get_run_param(run_param); /* Done */ return; } /* ************************************************************** */ /* * runparam_create_file * This function makes a full file name using the run parameters. * It checks to make sure a file with that name does not already exist. * It creates any required directories to make the path specified in the * file name. * It creates a file with the specified file name. * * Input: * run_param, structure containing the run parameters * base_name, basic name for file, eg. logfile, wiredat, harplt, ... * * Output: * err, 0 = ok, otherwise there was a problem * file_name, full name including the directory path and extension * * Zachary Wolf * 11/19/99 */ int runparam_create_file(struct run_param_struct run_param, char* base_name, char* file_name) { /* Declare variables */ int run_num; char ext[4]; int file_handle; char directory[80]; int status; FILE* file_ptr; /* Construct an extension for the file */ Scan(run_param.run_num, "%s>%i", &run_num); if (run_num >= 1 && run_num < 10) Fmt(ext, "%s= 10 && run_num < 100) Fmt(ext, "%s= 100 && run_num < 1000) Fmt(ext, "%s<%i", run_num); else { printf("Invalid run number, try again...\n"); Beep(); return 1; } /* Construct a file name from the run parameters */ Fmt(file_name, "%s\n"); } /* Update the index file */ fprintf(file_ptr, "%8.8s", DateStr()); fprintf(file_ptr, " %8.8s", TimeStr()); fprintf(file_ptr, " %3.3s", run_param.run_num); fprintf(file_ptr, " %10.10s", run_param.meas_dev); fprintf(file_ptr, " %4.4s", run_param.operator); fprintf(file_ptr, " %-s", run_param.comment); fprintf(file_ptr, "\n"); /* Close the file */ fclose(file_ptr); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * runparam_error * This function handles errors for the run parameter module. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 11/19/99 */ void runparam_error(char* message) { /* Declare variables */ char buf[80]; /* Notify the operator of the error */ printf("\nERROR: %s\n", message); Beep(); Delay(.5); Beep(); /* Terminate the program if the operator desires */ printf("Press ENTER to continue.\nPress any key then ENTER to terminate program.\n"); fgets(buf, 80, stdin); if (buf[0] == '\n') return; else exit(0); }