Changeset 226 for trunk/SRC/ToBeReviewed/STRING/strtok.pro
- Timestamp:
- 03/16/07 10:22:26 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/ToBeReviewed/STRING/strtok.pro
r186 r226 4 4 ; @file_comments 5 5 ; Retrieve portion of string up to token. 6 ; 6 ; 7 7 ; @categories 8 8 ; String … … 10 10 ; @param STRING {in}{required} 11 11 ; String to be split. Contains text after in, out token on output. 12 ; 12 ; 13 13 ; @param TOKEN {in}{required} 14 ; Token to use in splitting old. 14 ; Token to use in splitting old. 15 15 ; 16 ; @keyword TRIM 16 ; @keyword TRIM 17 17 ; set to remove leading blanks from old before returning. 18 18 ; 19 19 ; @keyword HELP 20 20 ; print useful message and exit. 21 ; 21 ; 22 22 ; @returns 23 23 ; new -- portion of string up to token. out … … 28 28 ; Token may be one or more characters. 29 29 ; if token is not found, returns old and sets old to ''. 30 ; 30 ; 31 31 ; @examples 32 32 ; If old is 'foo44 bar', then strtok( old, '44' ) would return … … 58 58 ; Copyright (C) 1996 The Regents of the University of California, All 59 59 ; Rights Reserved. Written by Matthew W. Craig. 60 ; See the file COPYRIGHT for restrictions on distr ubting this code.60 ; See the file COPYRIGHT for restrictions on distributing this code. 61 61 ; This code comes with absolutely NO warranty; see DISCLAIMER for details. 62 62 ; … … 74 74 On_error, 2 75 75 76 IF (n_params() NE 2) OR keyword_set(Help) THEN BEGIN 76 IF (n_params() NE 2) OR keyword_set(Help) THEN BEGIN 77 77 offset = ' ' 78 78 print, offset+'Retrieve portion of string up to token.' … … 102 102 print, offset+offset+" new='xyz' and old=''." 103 103 return, -1 104 ENDIF 104 ENDIF 105 105 106 106 pos = strpos(string, token) 107 107 108 108 IF (pos GE 0) THEN BEGIN 109 front = strmid(string, 0, pos) 109 front = strmid(string, 0, pos) 110 110 string = strmid(string, pos + strlen(token), strlen(string)) 111 111 IF keyword_set(trim) THEN string = strtrim(string, 1) 112 112 return, front 113 113 ENDIF 114 114 115 115 front = string 116 116 string = '' 117 117 return, front 118 118 119 119 END 120 120
Note: See TracChangeset
for help on using the changeset viewer.