ToBeReviewed/STRING/
chkeywd.pro
In a string containing an order to execute with EXECUTE by example.
We change the value of one of keywords.
More generally, in a string, we look for the character
chain: ', keywdname= ..., and we change the value of...
chkeywd
String, keywords
result = chkeywd(stringin, keywdname, keywdvalue, SEPARATOR=SEPARATOR, AFTER=AFTER)
Return value
stringout=stringin modified if keywdname has been found in stringin
Parameters
stringin
in
required
type: string
it is a string
keywdname
in
required
type: string
it is a string designating the name of keyword to look for.
keywdvalue
in
required
The new value of the keyword to considerate in STRINGIN
Keywords
SEPARATOR
To look for the keyword, we look for the first sign = which follow
the position of keywdname. By default, we substitute the string
before the comma. With the keyword SEPARATOR,we can modify the cut
of the string. SEPARATOR give a Character before the one we have to
look for the comma which delimit the keyword in the string.
(see examples)
AFTER
To look for the keyword, we look for the first sign = which follow
the position of keywdname. By default, we substitute the string
before the comma. With the keyword AFTER,we can modify the cut
of the string. AFTER give a Character after the one we have to
look for the comma which delimit the keyword in the string.
(see examples)
Examples
IDL> b='ok=111, year=[1997,1998,1999], age_capitaine=35'
IDL> print, b
ok=111, year=[1997,1998,1999], age_capitaine=35
IDL> print, chkeywd(b,'ok','c''est bon')
ok='c''est bon', year=[1997,1998,1999], age_capitaine=35
IDL> print, chkeywd(b,'YEAR',indgen(5),sep='=')
ok=111, year=[0,1,2,3,4], age_capitaine=35
IDL> print, chkeywd(b,'YEAR',indgen(5),sep=']',/after)
ok=111, year=[0,1,2,3,4], age_capitaine=35
IDL> b='ok=111, /year, /age_capitaine'
IDL> print, chkeywd(b,'year','c''est bon')
ok=111, year='c''est bon', /age_capitaine
Version history
Version
$Id: chkeywd.pro 372 2008-08-08 12:31:53Z pinsard $
History
Sebastien Masson (smasson@lodyc.jussieu.fr)
- 18/10/1999
- 24/11/1999: adaptation for keywords starting by /
Known issues
Restrictions
If keywdvalue is an array, it will be convert in a vector.
Beware, this function has loops, ifs and cases everywhere. So it can
not be used by big keywords (with a lot of elements which are big
arrays). The input keyword must not contain Complex floatings, structure,
Double-precision complex, Pointer, Object reference, Unsigned Integer,
Unsigned Longword Integer, 64-bit Integer or Unsigned 64-bit Integer.
Other attributes
Uses routines
common
Produced by IDLdoc 2.0.