Changeset 495 for trunk/SRC/ToBeReviewed/STRING
- Timestamp:
- 04/17/14 10:49:43 (10 years ago)
- Location:
- trunk/SRC/ToBeReviewed/STRING
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/ToBeReviewed/STRING/chkeywd.pro
r372 r495 5 5 ; We change the value of one of keywords. 6 6 ; 7 ; More generally, in a string, we look for the character 7 ; More generally, in a string, we look for the character 8 8 ; chain: ', keywdname= ..., and we change the value of... 9 9 ; … … 51 51 ; Double-precision complex, Pointer, Object reference, Unsigned Integer, 52 52 ; Unsigned Longword Integer, 64-bit Integer or Unsigned 64-bit Integer. 53 ;54 53 ; 55 54 ; @examples -
trunk/SRC/ToBeReviewed/STRING/delchr.pro
r325 r495 3 3 ; @file_comments 4 4 ; Delete all occurrences of a character from a text string. 5 ; 5 ; 6 6 ; @categories 7 7 ; 8 8 ; @param OLD {in}{required} 9 9 ; original text string. 10 ; 10 ; 11 11 ; @param C {in}{required} 12 12 ; character to delete. … … 16 16 ; @returns 17 17 ; new = resulting string. 18 ; 18 ; 19 19 ; @history 20 20 ; R. Sterner. 5 Jul, 1988. … … 37 37 compile_opt idl2, strictarrsubs 38 38 ; 39 39 40 40 if (n_params(0) lt 2) or keyword_set(hlp) then begin 41 41 ras = report(['Delete all occurrences of a character from a text string.', $ … … 46 46 return, -1 47 47 endif 48 48 49 49 B = BYTE(OLD) ; convert string to a byte array. 50 50 CB = BYTE(C) ; convert char to byte. -
trunk/SRC/ToBeReviewed/STRING/getfile.pro
r374 r495 36 36 ; 37 37 ; search the file in the all !path directories (use <pro>find</pro>) 38 ; when using /find keyword. Use <proidl>SPAWN</proidl>, 'cat...' for 38 ; when using /find keyword. Use <proidl>SPAWN</proidl>, 'cat...' for 39 39 ; unix os. 40 40 ; -
trunk/SRC/ToBeReviewed/STRING/isnumber.pro
r493 r495 14 14 ; 15 15 ; @returns 16 ; x = optionally returned numeric value if valid. 17 ; i = test flag: 16 ; x = optionally returned numeric value if valid. 17 ; i = test flag: 18 18 ; 0: not a number. 19 19 ; 1: txt is a long integer. … … 21 21 ; -1: first word of txt is a long integer. 22 22 ; -2: first word of txt is a float. 23 ; 23 ; 24 24 ; @history 25 25 ; - R. Sterner. 15 Oct, 1986. Johns Hopkins Applied Physics Lab. … … 41 41 ; 42 42 compile_opt idl2, strictarrsubs 43 ; 43 ; 44 44 if (n_params(0) lt 1) or keyword_set(hlp) then begin 45 45 print,' Determine if a text string is a valid number.' … … 55 55 return, -1 56 56 endif 57 57 58 58 txt = strtrim(txt0,2) ; trim blanks. 59 59 x = 0 ; define X. 60 60 61 61 if txt eq '' then return, 0 ; null string not a number. 62 62 63 63 sn = 1 64 64 if nwrds(txt) gt 1 then begin ; get first word if more than one. … … 66 66 txt = getwrd(txt,0) 67 67 endif 68 68 69 69 f_flag = 0 ; Floating flag. 70 70 b = byte(txt) ; Convert to byte array. … … 102 102 ;----- Allow no alphabetic characters ----------- 103 103 if total((b ge 65) and (b le 122)) ne 0 then return, 0 104 104 105 105 c = strmid(t,0,1) 106 106 if (c lt '0') or (c gt '9') then return, 0 ; First char not a digit. 107 107 108 108 x = txt + 0.0 ; Convert to a float. 109 109 if f_flag eq 1 then return, 2*sn ; Was floating. … … 114 114 return, 2*sn 115 115 endelse 116 116 117 117 end -
trunk/SRC/ToBeReviewed/STRING/lenstr.pro
r493 r495 5 5 ; input: 6 6 ; str a single string or string array. 7 ; 7 ; 8 8 ; output: 9 9 ; result length of the string(s) in normalized units 10 ; the number of elements of RESULT matches the number of 11 ; elements of STRING. 10 ; the number of elements of RESULT matches the number of 11 ; elements of STRING. 12 12 ; 13 13 ; procedure: … … 25 25 ; University of California, Santa Barbara 26 26 ; 27 ; @todo seb 27 ; @todo seb 28 28 ; 29 29 ;- -
trunk/SRC/ToBeReviewed/STRING/nwrds.pro
r372 r495 3 3 ; @file_comments 4 4 ; Return the number of words in the given text string. 5 ; 5 ; 6 6 ; @categories 7 7 ; … … 11 11 ; @keyword DELIMITER 12 12 ; = d. Set delimiter character (def = space). 13 ; 13 ; 14 14 ; @keyword HELP 15 15 ; 16 16 ; @returns 17 17 ; n = number of words found. 18 ; 18 ; 19 19 ; @restrictions 20 20 ; See also <pro>getwrd</pro> 21 ; 21 ; 22 22 ; @history 23 23 ; - R. Sterner, 7 Feb, 1985. Johns Hopkins University Applied Physics Laboratory. … … 38 38 compile_opt idl2, strictarrsubs 39 39 ; 40 40 41 41 if (n_params(0) lt 1) or keyword_set(hlp) then begin 42 42 print,' Return the number of words in the given text string.' … … 49 49 return, -1 50 50 endif 51 51 52 52 if strlen(txtstr) eq 0 then return,0 ; A null string has 0 words. 53 53 ddel = ' ' ; Default word delimiter is a space. … … 61 61 x = tb ne tst ; Locate words. 62 62 x = [0,x,0] ; Pad ends with delimiters. 63 63 64 64 y = (x-shift(x,1)) eq 1 ; Look for word beginnings. 65 65 66 66 n = fix(total(y)) ; Count word beginnings. 67 67 68 68 return, n 69 69 70 70 end -
trunk/SRC/ToBeReviewed/STRING/putfile.pro
r374 r495 3 3 ; @file_comments 4 4 ; Write a text file from a string array. 5 ; 5 ; 6 6 ; @categories 7 7 ; … … 14 14 ; @keyword ERROR 15 15 ; error flag: 0=ok, 1=invalid string array. 16 ; 16 ; 17 17 ; @history 18 18 ; - R. Sterner, 20 Mar, 1990 … … 33 33 compile_opt idl2, strictarrsubs 34 34 ; 35 35 36 36 if (n_params(0) lt 1) or keyword_set(hlp) then begin 37 37 print,' Write a text file from a string array.' … … 48 48 return 49 49 endif 50 ; 50 ; 51 51 if size(s, /type) ne 7 then begin 52 52 print,' Error in putfile: argument must be a string array.' … … 54 54 return 55 55 endif 56 56 57 57 get_lun, lun 58 58 openw, lun, file 59 59 60 60 for i = 0, n_elements(s)-1 do begin 61 61 t = s[i] … … 63 63 printf, lun, t 64 64 endfor 65 65 66 66 close, lun 67 67 free_lun, lun 68 68 err = 0 69 69 return 70 70 71 71 end -
trunk/SRC/ToBeReviewed/STRING/string2struct.pro
r374 r495 39 39 ; 40 40 ; @param STRVAL {IN}{REQUIRED} 41 ; String set up as keywords. Keywords require a little special treatment. 41 ; String set up as keywords. Keywords require a little special treatment. 42 42 ; Such as 43 43 ; -
trunk/SRC/ToBeReviewed/STRING/strkeywd.pro
r372 r495 2 2 ; 3 3 ; @file_comments 4 ; Translate a structure in a string able to be used to specify keywords 4 ; Translate a structure in a string able to be used to specify keywords 5 5 ; in the calling of a function when we use EXECUTE (see example) 6 6 ; 7 ; @categories 8 ; 7 ; @categories 8 ; 9 9 ; @param STRUCT 10 10 ; a structure … … 12 12 ; @returns 13 13 ; a string composed like following: 14 ; For each element of the structure, we write a part of the string as: 14 ; For each element of the structure, we write a part of the string as: 15 15 ; 'name_of_the_element=content_of_the_element' 16 16 ; 17 17 ; @restrictions 18 ; If an element of the structure contain an array, it will be convert in a 18 ; If an element of the structure contain an array, it will be convert in a 19 19 ; vector. 20 20 ; 21 21 ; @restrictions 22 ; Beware, this function has loops, ifs and cases everywhere. So it can 23 ; not be used by big keywords (with a lot of elements which are big 24 ; arrays). The input keyword must not contain Complex floatings, structure, 25 ; Double-precision complex, Pointer, Object reference, Unsigned Integer, 22 ; Beware, this function has loops, ifs and cases everywhere. So it can 23 ; not be used by big keywords (with a lot of elements which are big 24 ; arrays). The input keyword must not contain Complex floatings, structure, 25 ; Double-precision complex, Pointer, Object reference, Unsigned Integer, 26 26 ; Unsigned Longword Integer, 64-bit Integer or Unsigned 64-bit Integer. 27 27 ; -
trunk/SRC/ToBeReviewed/STRING/strright.pro
r374 r495 6 6 ; @categories 7 7 ; String 8 ; 8 ; 9 9 ; @param S {in}{required} 10 10 ; the string to be searched … … 20 20 ; 21 21 ; @examples 22 ; 22 ; 23 23 ; add a "/" in to path if it "/" is not at the end : 24 24 ; … … 48 48 compile_opt idl2, strictarrsubs 49 49 ; 50 50 51 51 on_error,2 ; return to caller 52 52 53 53 if (n_elements(s) le 0) then return,-1L 54 54 55 55 l = strlen(s) 56 56 57 57 if (n_elements(lastn) le 0) then lastn = 1 58 58 if lastn gt l then lastn = l 59 59 60 60 result = strmid(s,l-lastn,l) 61 61 62 62 return,result 63 63 end -
trunk/SRC/ToBeReviewed/STRING/strsci.pro
r374 r495 15 15 ; The format specification used in the string 16 16 ; conversion for the mantissa (i.e. the 17 ; "A" of "A x 10^B"). 17 ; "A" of "A x 10^B"). 18 18 ; 19 19 ; @keyword POT_ONLY … … 41 41 ; 42 42 ; IDL> Result = STRSCI( 2000000, format='(i1)' ) 43 ; IDL> print, result 43 ; IDL> print, result 44 44 ; 2 x 10!u6!n 45 ; 46 ; which gets plotted as 2 x 10 47 ; 45 ; 46 ; which gets plotted as 2 x 10 47 ; 48 48 ; IDL> Result = STRSCI( -0.0001 ) 49 49 ; IDL> print, result … … 55 55 ; IDL> print, result 56 56 ; 0.00000000 57 ;58 57 ; 59 58 ; @history … … 76 75 ; - now can handle DATA=0.0 correctly 77 76 ; - updated comments 78 ; mgs, 03 Jun 1999: 77 ; mgs, 03 Jun 1999: 79 78 ; - can now also handle values lt 1 ;-) 80 79 ; - and doesn't choke on arrays … … 83 82 ; $Id$ 84 83 ; 85 ; Copyright (C) 1998, 1999 Bob Yantosca and Martin Schultz, 84 ; Copyright (C) 1998, 1999 Bob Yantosca and Martin Schultz, 86 85 ; Harvard University 87 86 ; This software is provided as is without any warranty … … 125 124 ;==================================================================== 126 125 if ( Abs( Data[i] ) ne 0.0 ) then begin 127 126 128 127 ; take the common log and store in LOG10DATA 129 Log10Data = ALog10( Abs( Data[i] ) ) 130 128 Log10Data = ALog10( Abs( Data[i] ) ) 129 131 130 ; Boolean flag if data < 0 132 sign = ( Data[i] lt 0.0 ) 133 131 sign = ( Data[i] lt 0.0 ) 132 134 133 ; Compute the characteristic (int part) 135 134 ; Add the 1d-6 to prevent roundoff errors 136 135 Characteristic = Fix( Log10Data + 1.0d-6 ) 137 136 if (Log10Data lt 0) then $ 138 Characteristic = Characteristic - 1 139 137 Characteristic = Characteristic - 1 138 140 139 ; Compute the Mantissa (frac part) and take its antilog. 141 Mantissa = Log10Data - Characteristic 140 Mantissa = Log10Data - Characteristic 142 141 Mantissa = 10.0^Mantissa 143 142 144 143 ; print,data[i],log10data,mantissa,characteristic,format='(3f24.14,i8)' 145 146 ; String for the coefficient part, 144 145 ; String for the coefficient part, 147 146 ; The coefficient is just antilog of the Mantissa 148 147 ; Add the minus sign if DATA < 0.0 149 148 A = StrTrim( String( Mantissa, Format=Format ), 2 ) 150 149 if ( Sign ) then A = '-' + A 151 150 152 151 ; String for the power of 10 part 153 152 B = '10!u' + strtrim( string( Characteristic ), 2 ) + '!n' … … 156 155 if ( Characteristic eq 1 ) then B = '10' 157 156 endif 158 157 159 158 ; composite string 160 159 Result[i] = A + ' x ' + B 161 160 if ( Short AND B eq '1') then Result[i] = A 162 163 161 164 162 ;==================================================================== 165 163 ; If DATA = 0, then we cannot take the common log, so return … … 170 168 B = A 171 169 Result[i] = A 172 170 173 171 endelse 174 172 175 173 ;==================================================================== 176 174 ; Return result to calling program (depending on keyword settings) … … 183 181 if ( Trim ) then $ 184 182 Result[i] = StrCompress( Result[i], /Remove_All ) 185 183 186 184 endfor 187 185 188 186 if (n_elements(Result) eq 1) then $ 189 187 Result = Result[0] 190 188 191 189 return, Result 192 190 -
trunk/SRC/ToBeReviewed/STRING/strsed.pro
r372 r495 1 1 ;+ 2 2 ; 3 ; @file_comments 3 ; @file_comments 4 4 ; replace one (or more) character(s)/string(s) in a string array 5 5 ; "modern" version of the obsolete strrepl … … 18 18 ; 19 19 ; @keyword FOLD_CASE 20 ; Indicates that the regular expression matching should be done in 20 ; Indicates that the regular expression matching should be done in 21 21 ; a case-insensitive fashion. 22 22 ; … … 54 54 strout[line[i]] = strjoin(strsplit(strout[line[i]], exp1, /extract $ 55 55 , /regex, /preserve_null, FOLD_CASE = fold_case), exp2) 56 ENDIF 56 ENDIF 57 57 ; 58 58 return, strout -
trunk/SRC/ToBeReviewed/STRING/tostr.pro
r372 r495 4 4 ; Convert an input in a string. 5 5 ; 6 ; @categories 6 ; @categories 7 7 ; String 8 8 ; … … 21 21 ; 22 22 ; @restrictions 23 ; Beware, this function has loops, ifs and cases everywhere. So it can 24 ; not be used by big keywords (with a lot of elements which are big 23 ; Beware, this function has loops, ifs and cases everywhere. So it can 24 ; not be used by big keywords (with a lot of elements which are big 25 25 ; arrays). 26 ; 26 ; 27 27 ; @examples 28 28 ; IDL> help, tostr(1),tostr('a'),tostr(indgen(4)),tostr(['a','jkfjo']) … … 48 48 49 49 case 1 of 50 size(input, /type) LE 5:BEGIN 50 size(input, /type) LE 5:BEGIN 51 51 if size(input, /type) EQ 1 then input = long(input) 52 52 if n_elements(input) EQ 1 then res = strtrim(input, 1) $ 53 ELSE BEGIN 53 ELSE BEGIN 54 54 res = '['+strtrim((input)[0], 1) 55 55 for i = 1, n_elements(input)-1 do res = res+','+strtrim((input)[i], 1) 56 56 res = res+']' 57 ENDELSE 57 ENDELSE 58 58 END 59 size(input, /type) eq 7:BEGIN 59 size(input, /type) eq 7:BEGIN 60 60 if n_elements(input) EQ 1 then BEGIN 61 61 sinput = strrepl(input, '''', '''''') 62 62 res = ''''+sinput+'''' 63 ENDIF ELSE BEGIN 63 ENDIF ELSE BEGIN 64 64 res = '['''+strrepl(input[0], '''', '''''')+'''' 65 65 for i = 1, n_elements(input)-1 do res = res+','''+strrepl(input[i], '''', '''''')+'''' 66 66 res = res+']' 67 ENDELSE 67 ENDELSE 68 68 END 69 ELSE:BEGIN 69 ELSE:BEGIN 70 70 ras = report('la fonction tostr ne marche pas pour input qui est de type '+size(input, /tname)) 71 71 res = ''
Note: See TracChangeset
for help on using the changeset viewer.