📄 getpars.par.lib
字号:
GETPARS - Functions to GET PARameterS from the command line. Numeric parameters may be single values or arrays of int, uint, short, ushort, long, ulong, float, or double. Single character strings (type string or char *) may also be gotten. Arrays of strings, delimited by, but not containing commas are permitted.The functions are:initargs Makes command line args available to subroutines (re-entrant). Every par program starts with this call!getparint get integersgetparuint get unsigned integersgetparshort get short integersgetparushort get unsigned short integersgetparlong get long integers getparulong get unsigned long integersgetparfloat get floatgetpardouble get doublegetparstring get a single stringgetparstringarray get string array (fields delimited by commas) getpar get parameter by typegetnparint get n'th occurrence of integergetnparuint get n'th occurrence of unsigned intgetnparshort get n'th occurrence of short integergetnparushort get n'th occurrence of unsigned short intgetnparlong get n'th occurrence of long integergetnparulong get n'th occurrence of unsigned long intgetnparfloat get n'th occurrence of float getnpardouble get n'th occurrence of double getnparstring get n'th occurrence of string getnparstringarray get n'th occurrence of string arraygetnpar get n'th occurrence by typecountparname return the number of times a parameter names is usedcountparval return the number of values in the last occurrence of a parametercountnparval return the number of values in the n'th occurrence of a parametergetPar Promax compatible version of getparFunction Prototypes:void initargs (int argc, char **argv);int getparint (char *name, int *p);int getparuint (char *name, unsigned int *p);int getparshort (char *name, short *p);int getparushort (char *name, unsigned short *p);int getparlong (char *name, long *p);int getparulong (char *name, unsigned long *p);int getparfloat (char *name, float *p);int getpardouble (char *name, double *p);int getparstring (char *name, char **p);int getparstringarray (char *name, char **p);int getnparint (int n, char *name, int *p);int getnparuint (int n, char *name, unsigned int *p);int getnparshort (int n, char *name, short *p);int getnparushort (int n, char *name, unsigned short *p);int getnparlong (int n, char *name, long *p);int getnparulong (int n, char *name, unsigned long *p);int getnparfloat (int n, char *name, float *p);int getnpardouble (int n, char *name, double *p);int getnparstring (int n, char *name, char **p);int getnparstringarray (int n, char *name, char **p);int getnpar (int n, char *name, char *type, void *ptr);int countparname (char *name);int countparval (char *name);int countnparval (int n, char *name);void getPar(char *name, char *type, void *ptr);Notes:Here are some usage examples: ... if integer n not specified, then default to zero. if (!getparint("n", &n)) n = 0; ... if array of floats vx is specified, then if (nx=countparval("vx")) { ... allocate space for array vx = ealloc1float(nx); ... and get the floats getparfloat("vx",vx); } The command line for the above examples might look like: progname n=35 vx=3.21,4,9.5 Every par program starts with this call!More examples are provided in the DTEST code at the end of this file.The functions: eatoh, eatou, eatol, eatov, eatoi, eatop usedbelow are versions of atoi that check for overflow. The sourcefile for these functions is atopkge.c.Authors:Rob Clayton & Jon Claerbout, Stanford University, 1979-1985Shuki Ronen & Jack Cohen, Colorado School of Mines, 1985-1990Dave Hale, Colorado School of Mines, 05/29/90Credit to John E. Anderson for re-entrant initargs 03/03/94
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -