Changeset 142 for trunk/SRC/ToBeReviewed/STRING/chkeywd.pro
- Timestamp:
- 07/21/06 14:47:49 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/ToBeReviewed/STRING/chkeywd.pro
r134 r142 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; NAME: chkeywd (change keyword)6 5 ; 7 ; PURPOSE: ds un string qui contient une commande a executer avec 8 ; EXECUTE par ex. On change la valeur d''un des mot cle. 9 ; Plus generalement, ds un string, on cherche la chaine de 10 ; chacarteres: ', keywdname= ..., et on change la valeur de ... 6 ; @file_comments 7 ; In a string containing an order to executewith EXECUTE by example. 8 ; We change the value of one of keywords. 9 ; More generally, in a string, we look for the caracter chain: ', keywdname= ..., 10 ; and we change the value of... 11 11 ; 12 ; CATEGORY: pour bidouiller des commandes passees par execute 12 ; @categories 13 ; string, keywords 13 14 ; 14 ; CALLING SEQUENCE: stringout=chkeywd(stringin, keywdname, keywdvalue)15 15 ; 16 ; INPUTS: 17 ; stringin: un string 18 ; keywdname: un string designant le nom du mot clef a chercher. 19 ; keywdvalue: nouvelle valeur du mot clef a considerer ds stringin 16 ; @param STRINGIN {in}{required} 17 ; it is a string 20 18 ; 21 ; KEYWORD PARAMETERS: 22 ; pour chercher le mot cle, on cherche le premier signe = qui 23 ; suit la position de keywdname. on substitue 24 ; pardefaut tout le bout de string qui suit jusqu''a la prochaine 25 ; virgule. avec les mots cles SEPARATOR et AFTER on peut modifier 26 ; cette decoupe du string: 27 ; SEPARATOR donne un chatactere avant (ou apres si AFTER est 28 ; active) lequel il faut chercher la virgule qui delimite le mot 29 ; cle ds le string. cf. les exemples 19 ; @param KEYWDNAME {in}{required} 20 ; it is a string designating the name of keyword to look for. 30 21 ; 31 ; OUTPUTS:stringout=stringin modifie si keywdname a ete trouve ds32 ; stringin22 ; @param KEYWDVALUE {in}{required} 23 ; The new value of the keyword to considerate in STRINGIN 33 24 ; 34 ; COMMON BLOCKS:common.pro 25 ; @keyword SEPARATOR 26 ; To look for the keyword, we look for the first sign = which follow 27 ; the position of keywdname. By default, we substitute the string 28 ; before the comma. With the keyword SEPARATOR,we can modify the cut 29 ; of the string. SEPARATOR give a caractere before the one we have to 30 ; look for the comma which delimit the keyword in the string. 31 ; (see examples) 35 32 ; 36 ; SIDE EFFECTS: 37 ; 38 ; Si keywdvalue est un tableau, il sera convertit en vecteur. 33 ; @keyword AFTER 34 ; To look for the keyword, we look for the first sign = which follow 35 ; the position of keywdname. By default, we substitute the string 36 ; before the comma. With the keyword AFTER,we can modify the cut 37 ; of the string. AFTER give a caractere after the one we have to 38 ; look for the comma which delimit the keyword in the string. 39 ; (see examples) 39 40 ; 40 ; RESTRICTIONS: 41 ; @returns 42 ; stringout=stringin modified if keywdname has been found in stringin 41 43 ; 42 ; attention cette fonction comporte des boucles, des if et des cases 43 ; ds tous les sens. Elle ne doit donc pas etre utilisee avec des 44 ; mots clefs de grosse taille (avec bcp d''elements et avec des 45 ; elements etant de gros tableaux). 46 ; le mot clef en entree ne doit pas contenir de Complex floating, de 47 ; structure, de Double-precision complex, de Pointer, de Object 48 ; reference, de Unsigned Integer, de Unsigned Longword Integer, de 49 ; 64-bit Integer, de Unsigned 64-bit Integer 44 ; @uses 45 ; common.pro 50 46 ; 51 ; EXAMPLE: 47 ; @restrictions 48 ; If keywdvalue is an array, it will be convert in a vector. 49 ; 50 ; @restrictions 51 ; Beware, this function has loops, ifs ad cases everywhere. So it can 52 ; not be used by big keywords (with a lot of elements which are big 53 ; arrays). The input keyword must not contain Complex floatings, structure, 54 ; Double-precision complex, Pointer, Object reference, Unsigned Integer, 55 ; Unsigned Longword Integer, 64-bit Integer or Unsigned 64-bit Integer. 56 ; 57 ; 58 ; @examples 52 59 ; 53 60 ; IDL> b='ok=111, year=[1997,1998,1999], age_capitaine=35' … … 64 71 ; ok=111, year='c''est bon', /age_capitaine 65 72 ; 66 ; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr) 73 ; @history 74 ; Sebastien Masson (smasson@lodyc.jussieu.fr) 67 75 ; 18/10/1999 68 ; 24/11/1999: adaptation pour les mots cles 69 ; commencant par / 76 ; 24/11/1999: adaptation for keywords starting by / 77 ; 78 ; @version 79 ; $Id$ 80 ; 70 81 ;- 71 82 ;------------------------------------------------------------ … … 81 92 if poskeywd EQ -1 then return, stringout 82 93 while poskeywd NE -1 do BEGIN 83 ; change r un mot cle qui commence par/toto94 ; change a keyword starting by /toto 84 95 if strmid(stringout,poskeywd-1,1) EQ '/' then BEGIN 85 96 ajoute = keywdname+'='+tostr(keywdvalue) … … 88 99 poskeywd = strpos(stringout, keywdname, poskeywd) 89 100 ENDIF ELSE BEGIN 90 ; change r un mot cle qui commence partoto=101 ; change a keyword sarting by toto= 91 102 posegal = strpos(stringout, '=', poskeywd) 92 103 if posegal EQ -1 then return, stringout
Note: See TracChangeset
for help on using the changeset viewer.