ocparse (Aug2004) |
rjtools
|
ocparse (Aug2004) |
ocparse
ocparse - (old cparse) parse a character string into fields given
an arbitrary field delimiter
ocparse cline [delim] [nselect]
- cline = ""
- Character string to parse into fields.
- delim = " "
- Arbitrary field delimiting character or multi-character string. 'delim'
defaults to a single space character.
- nselect = 0
- Return the value of the 'nselect'th field in 'cline'.
- (nfields) [int]
- Parameter returning the total number of fields found in 'cline'.
- (field1, field2, field3, .. , field15) [string]
- Parameters returning the values of fields 1 through 15 where fields in
excess of 'nfields' are left at their default values of "INDEF".
- (cfield) [string]
- Parameter returning the value of field number 'nselect' in string 'cline'.
Task to parse a character string 'cline' into separate fields, given an
arbitrary field delimiting character (e.g., " ", ":", ",", "/") or
multi-character string (e.g., "//", ".fits", "-->"). Leading and multiple
successive delimiters are ignored in the case of "white-space" delimiters
(" " and <tab>), but are presumed to be significant otherwise. A
user-specified field (parameter 'nselect') is returned in task parameter
'cfield'. The total number of fields found in 'cline' is returned in task
parameter 'nfields'. At most 15 field can be parsed. If the number of
fields actually found in 'cline' exceeds 15, 'field15' will return the
15-th and remaining fields in the input character string.
Usually, a string contains at least one field (which is equal to the
entire input string if the specified delimiter does not occur in
'cline'). 'cfield' will be returned "INDEF" upon exit when 'nselect'
equals 0, INDEF', or is larger than 'nfields', as well as in the case
that 'cline' equals 'delim' and 'delim' is a white-space character.
ocparse ("a0061.fits: NGC4594 B 300s -01:32:15 1.324",
delim=":", nsel=1)
s1 = ocparse.cfield
ocparse ("a0061.fits: NGC4594 B 300s -01:32:15 1.324",
delim=" ", nsel=0)
s2 = ocparse.field2
s3 = ocparse.field3
rj> imcopy (s1, s2//s3//".fits", verbose+)
a0061.fits -> NGC4594B.fits
Note, that the multiple space characters are collapsed in the second call
to 'ocparse'. Although the input string to parse in this example is given
explicitly, normally it would be a string-valued variable obtained through
some other means (e.g., 'fscan' or 'rjtools.rdlist') that is passed to
'ocparse'.
- CPARSE v2.10, Apr 23 1996 [R.A. Jansen]
- Original fixed 15-field version of this task; IRAF 2.10.4
- CPARSE v2.11, Jun 28 2000 [RAJ]
- Added option to select a specific field by giving its
field number; IRAF 2.11.3
- CPARSE / OCPARSE v2.12, Jul 29 2003 [RAJ]
- Complete revision of this task: did away with the fixed fields and
increased flexibility. There no longer is any limitation on the number
of fields, and ignoring of leading and embedded multiple delimiters can
be switched on and off separately; the original version was renamed to
'ocparse' and cleaned-up a bit. It remains part of the 'rjtools' package,
because 'tcolarit' and 'imregister', and some other user tasks at present
still require the old version; IRAF 2.12.1
Strings containing parentheses, "(" or ")", result in an error:
"ambiguous parameter `' within `<searchpath>'"
Is there a work-around valid for CL scripts?