Revision: | 1.1 |
Committed: | Fri Feb 18 00:21:17 2011 UTC (12 years, 7 months ago) by richard |
Branch: | MAIN |
CVS Tags: | Ver_6-0, Ver_6-1, Ver_6-2, Ver_6-3, Ver_6-4, Ver_9-1, Ver_5-14, Ver_5-13, Ver_LATEST, Ver_9-3, Ver_9-41, Ver_9-2, Ver_8-8, Ver_8-2, Ver_8-3, Ver_8-0, Ver_8-1, Ver_8-6, Ver_8-7, Ver_8-4, Ver_8-5, Ver_7-1, Ver_7-0, Ver_9-5, Ver_9-4, Ver_8-10, Ver_8-11, Ver_8-12, Ver_9-0, HEAD |
Log Message: | IDL package for calculating pzt flatfields 2011.02.17 |
# | Content |
---|---|
1 | function gettok,st,char |
2 | ;+ |
3 | ; NAME: |
4 | ; GETTOK |
5 | ; PURPOSE: |
6 | ; Retrieve the first part of the string up to a specified character |
7 | ; EXPLANATION: |
8 | ; GET TOKen - Retrieve first part of string until the character char |
9 | ; is encountered. |
10 | ; |
11 | ; CALLING SEQUENCE: |
12 | ; token = gettok( st, char ) |
13 | ; |
14 | ; INPUT: |
15 | ; char - character separating tokens, scalar string |
16 | ; |
17 | ; INPUT-OUTPUT: |
18 | ; st - (scalar) string to get token from (on output token is removed) |
19 | ; |
20 | ; OUTPUT: |
21 | ; token - scalar string value is returned |
22 | ; |
23 | ; EXAMPLE: |
24 | ; If ST is 'abc=999' then gettok(ST,'=') would return |
25 | ; 'abc' and ST would be left as '999' |
26 | ; |
27 | ; NOTES: |
28 | ; A version of GETTOK that accepts vector strings is available for users |
29 | ; of IDL V5.3 or later from http://idlastro.gsfc.nasa.gov/ftp/v53/ |
30 | ; HISTORY |
31 | ; version 1 by D. Lindler APR,86 |
32 | ; Remove leading blanks W. Landsman (from JKF) Aug. 1991 |
33 | ; Converted to IDL V5.0 W. Landsman September 1997 |
34 | ;- |
35 | ;---------------------------------------------------------------------- |
36 | On_error,2 ;Return to caller |
37 | |
38 | ; if char is a blank treat tabs as blanks |
39 | |
40 | tab = string(9b) |
41 | while strpos(st,tab) GE 0 do begin ;Search for tabs |
42 | pos = strpos(st,tab) |
43 | strput,st,' ',pos |
44 | endwhile |
45 | |
46 | st = strtrim(st,1) ;Remove leading blanks |
47 | |
48 | ; find character in string |
49 | |
50 | pos = strpos(st,char) |
51 | if pos EQ -1 then begin ;char not found? |
52 | token = st |
53 | st = '' |
54 | return, token |
55 | endif |
56 | |
57 | ; extract token |
58 | |
59 | token = strmid(st,0,pos) |
60 | len = strlen(st) |
61 | if pos EQ (len-1) then st = '' else st = strmid(st,pos+1,len-pos-1) |
62 | |
63 | ; Return the result. |
64 | |
65 | return,token |
66 | end |