include # Column definitions for the output table. define ROOT_COLUMN_NAME "ROOTNAME" define ROOT 1 define DIODE_COLUMN_NAME "DIODE" define DIODE 2 define CRATE_COLUMN_NAME "COUNT RATE" define CRATE 3 define MEAN_COLUMN_NAME "MEAN" define MEAN 4 define SIGMA_COLUMN_NAME "SIGMA" define SIGMA 5 define MAX_COLUMNS 5 #--------------------------------------------------------------------------- .help noisy_table May 92 hrs .ih NAME dst_noisy_open -- Open the statistics tables. dst_noisy_write -- Write the statistics to the specified table. .endhelp #--------------------------------------------------------------------------- procedure dst_noisy_open (table_name, table, row) char table_name[ARB] # I: Name of table to open. pointer table # O: The table descriptor. int row # O: The current row of the table. # Declarations. int ip # Generic index. pointer sp # Stack pointer. pointer tmp # Temporary string. include "noisy_table.com" # Function prototypes. int access(), strlen(), tbpsta(), tbtacc() pointer tbtopn() begin # If no name is specified, no table is opened. if (strlen (table_name) == 0) { table = NULL } else { call smark(sp) call salloc (tmp, SZ_LINE, TY_CHAR) # Iniitalize the column names. call strcpy (ROOT_COLUMN_NAME, col_names[1,ROOT], SZ_COLNAME) call strcpy (DIODE_COLUMN_NAME, col_names[1,DIODE], SZ_COLNAME) call strcpy (CRATE_COLUMN_NAME, col_names[1,CRATE], SZ_COLNAME) call strcpy (MEAN_COLUMN_NAME, col_names[1,MEAN], SZ_COLNAME) call strcpy (SIGMA_COLUMN_NAME, col_names[1,SIGMA], SZ_COLNAME) if (access (table_name, 0, 0) == YES) { if (tbtacc (table_name) == YES) { table = tbtopn (table_name, READ_WRITE, 0) call tbcfnd (table, col_names, columns, MAX_COLUMNS) # Check to make sure all the columns exist. If one # doesn't die off. for (ip= 1; ip <= MAX_COLUMNS; ip = ip + 1) if (columns[ip] == NULL) { call sprintf (Memc[tmp], SZ_LINE, "column %s doesn't exist in table %s") call pargstr (col_names[1,ip]) call pargstr (table_name) call error (1, Memc[tmp]) } # Determine the next row to append. row = tbpsta (table, TBL_NROWS) + 1 } else { call sprintf (Memc[tmp], SZ_LINE, "file %s exists but isn't a table") call pargstr (table_name) call error (1, Memc[tmp]) } } else { table = tbtopn (table_name, NEW_FILE, 0) call tbcdef (table, columns[ROOT], col_names[1,ROOT], "", "%20s", -20, 1, 1) call tbcdef (table, columns[DIODE], col_names[1,DIODE], "", "%6d", TY_INT, 1, 1) call tbcdef (table, columns[CRATE], col_names[1,CRATE], "COUNT RATE", "%6.6g", TY_DOUBLE, 1, 1) call tbcdef (table, columns[MEAN], col_names[1,MEAN], "COUNT RATE", "%6.6g", TY_DOUBLE, 1, 1) call tbcdef (table, columns[SIGMA], col_names[1,SIGMA], "COUNT RATE", "%6.6g", TY_DOUBLE, 1, 1) call tbtcre (table) row = 1 } call sfree(sp) } end #--------------------------------------------------------------------------- # End of dst_noisy_open #--------------------------------------------------------------------------- # dst_noisy_write -- Write the statistics to the table. procedure dst_noisy_write (table, root, diode, crate, mean, sigma, row) pointer table # I: Table descriptor. char root[ARB] # I: Root name. int diode # I: The noisy diode. double crate # I: Count rate of diode. double mean # I: The mean count rate of all diodes. double sigma # I: The standard deviation. int row # IO: The current row of the table. # Declarations. include "noisy_table.com" # Function prototypes. int strlen() begin if (table != NULL) { call tbrptt (table, columns[ROOT], root, strlen (root), 1, row) call tbrpti (table, columns[DIODE], diode, 1, row) call tbrptd (table, columns[CRATE], crate, 1, row) call tbrptd (table, columns[MEAN], mean, 1, row) call tbrptd (table, columns[SIGMA], sigma, 1, row) row = row + 1 } end #--------------------------------------------------------------------------- # End of dst_noisy_write #---------------------------------------------------------------------------