fetch - grab a parameter from the command line or history file
int fetch(name, format, variable)
parameter name
format of variable (d,f,s)
variable value of variable
This function extracts values from input history file and command line expressions of the form `name=value'.
More than one name may be searched by separating the alternatives by blanks or commas. Possible format conversions are ``d'' (or ``i''), ``f'' (or ``r''), ``g'', ``s'' and ``1'' for integer, floating point, double precision, strings, and boolean respectively. (For boolean, y, Y, or 1 are returned as integer 1 and n, N, or 0 are returned as integer 0.) If no match is found, the variable is not altered.
When a keyword `par=filename' is encountered on the command line, that file (and any that it might in turn point to) is scanned as well. Fetch returns a count of the number of matches it found. It also copies the input history file to the output history file if this has not already been done.
Search and copy of the input history file can be supressed using the command line parameter `noheader=y'.
Some examples of how this routine works: | ||
Command | Input | Result |
fetch("nx","d",&nx)
nx=100 nx is set to 100, 1 argument found
fetch("nx","d",&nx)
nx= 0 arguments found
fetch("nx nxx","d",&nx)
nxx=30 nx is set to 30, 1 argument found
fetch("nx","d",&nx)
nx=50 nx=60 nx is set to 60, 2 arguments found
fetch("nt","d",&nx)
nx=80 0 arguments found
fetch("nt ntt","d", &nt)
ntt=30 nt=40 nt is set to 40, 2 arguments found
fetch("nt ntt","d", &nt)
nt=30 ntt=40 nt is set to 40, 2 arguments found
the getch manpage, the hetch manpage, the putch manpage, the auxpar manpage
Program execution is terminated with extreme prejudice if a par file cannot be opened or the command argument list cannot be found.
It should be possible to limit the length of retrieved strings and to extract individual characters. It is also not presently possible to redirect search to an internal argument list.
parameter input fetch
sep