external/CDAWlib/jh/
getwrd.pro
NAME: GETWRD PURPOSE: Return the n'th word from a text string. CATEGORY: CALLING SEQUENCE: wrd = getwrd(txt, n, [m]) INPUTS: txt = text string to extract from. in txt is allowed to be an array. n = word number to get (first = 0 = def). in m = optional last word number to get. in KEYWORD PARAMETERS: Keywords: LOCATION = l. Return word n string location. DELIMITER = d. Set word delimiter (def = space & tab). /LAST means n is offset from last word. So n=0 gives last word, n=-1 gives next to last, ... If n=-2 and m=0 then last 3 words are returned. /NOTRIM suppresses whitespace trimming on ends. NWORDS=n. Returns number of words in string. /KEEP_LEADING_DEL Keep any leading delimiter in result. /KEEP_TRAILING_DEL Keep any trailing delimiter in result. OUTPUTS: wrd = returned word or words. out COMMON BLOCKS: getwrd_com NOTES: Note: If a NULL string is given (txt="") then the last string given is used. This saves finding the words again. If m > n wrd will be a string of words from word n to word m. If no m is given wrd will be a single word. n<0 returns text starting at word abs(n) to string end If n is out of range then a null string is returned. See also nwrds. MODIFICATION HISTORY: Ray Sterner, 6 Jan, 1985. R. Sterner, Fall 1989 --- converted to SUN. R. Sterner, Jan 1990 --- added delimiter. R. Sterner, 18 Mar, 1990 --- added /LAST. R. Sterner, 31 Jan, 1991 --- added /NOTRIM. R. Sterner, 20 May, 1991 --- Added common and NULL string. R. Sterner, 13 Dec, 1992 --- Made tabs equivalent to spaces. R. Sterner, 4 Jan, 1993 --- Added NWORDS keyword. R. Sterner, 2001 Jan 15 --- Fixed to use first element if not a scalar. R. Sterner, 2006 Mar 07 --- Added /KEEP_LEADING_DEL, /KEEP_TRAILING_DEL. Also cleaned up some. R. Sterner, 2010 Apr 29 --- Converted arrays from () to []. R. Sterner, 2010 Jun 17 --- Added the /KEEP_* keywords to the help text. R. Sterner, 2011 Mar 23 --- Allowed txt to be an array. R. Sterner, 2011 Dec 12 --- Added /RESET keyword. R. Sterner, 2013 Feb 01 --- Made loop use long int. Copyright (C) 1985, Johns Hopkins University/Applied Physics Laboratory This software may be used, copied, or redistributed as long as it is not sold and this copyright notice is reproduced on each copy made. This routine is provided as is without any express or implied warranties whatsoever. Other limitations apply as described in the file disclaimer.txt.
Routines
top source GETWRD
result = GETWRD(TXTSTR, NTH, MTH, help=help, location=location, delimiter=delimiter, notrim=notrim, last=last, nwords=nwords, keep_leading_del=keep_leading_del, keep_trailing_del=keep_trailing_del, reset=reset)
Parameters
- TXTSTR
- NTH
- MTH
Keywords
- help
- location
- delimiter
- notrim
- last
- nwords
- keep_leading_del
- keep_trailing_del
- reset
File attributes
Modification date: | Tue Oct 21 13:53:43 2014 |
Lines: | 115 |