50c8cb8cf1dccffc3ee8b2c9ebded1c96fd6eba5 hiram Tue May 28 09:53:34 2013 -0700 improve usage message to include with userUtils refs #9149 diff --git src/utils/addCols/addCols.c src/utils/addCols/addCols.c index 6bf3a9f..bc7f494 100644 --- src/utils/addCols/addCols.c +++ src/utils/addCols/addCols.c @@ -1,50 +1,53 @@ /* addCols - Add together columns. */ #include "common.h" #include "linefile.h" void usage() /* Explain usage and exit. */ { errAbort( "addCols - Sum columns in a text file.\n" "usage:\n" - " addCols XXX\n"); + " addCols <fileName>\n" + "adds all numbers in all columns (up to 16 columns) " + "in the given file.\n" + "<fileName> can be the name: stdin to accept input from stdin."); } void addCols(char *fileName) /* addCols - Add together columns. */ { struct lineFile *lf; char *words[16]; int wordCount; static double totals[16]; int maxCount = 0; int i; if (sameString(fileName, "stdin")) lf = lineFileStdin(TRUE); else lf = lineFileOpen(fileName, TRUE); for (i=0; i<ArraySize(words); ++i) totals[i] = 0; while ((wordCount = lineFileChop(lf, words)) != 0) { if (maxCount < wordCount) maxCount = wordCount; for (i=0; i<wordCount; ++i) totals[i] += atof(words[i]); } for (i=0; i<maxCount; ++i) printf("%6.2f ", totals[i]); printf("\n"); } int main(int argc, char *argv[]) /* Process command line. */ { if (argc != 2) usage(); addCols(argv[1]); return 0; }