Ignore:
Timestamp:
03/14/07 18:13:39 (17 years ago)
Author:
pinsard
Message:

improvements of some *.pro

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SRC/Matrix/make_selection.pro

    r163 r223  
    11;+ 
    22; 
    3 ; file_comments  
     3; @file_comments 
    44; Convert an array of selected values to an index 
    5 ;        array that identifies the selected values in a list 
    6 ;        or data array.  
     5; array that identifies the selected values in a list or data array. 
    76; 
    8 ; categories tools 
    9 ;  
    10 ; @param NAMES {in}{required} A list or array of values to choose from  
     7; @categories 
     8; tools 
    119; 
    12 ; @param SELNAMES {in}{required} A list of selected values 
     10; @param NAMES {in}{required} 
     11; A list or array of values to choose from 
    1312; 
    14 ; @keyword ONLY_VALID Return only indexes of found values. Values not 
    15 ;            found are skipped. Default is to return 1 index value for 
    16 ;            each SELNAME, which is -1 if SELNAME is not contained in  
    17 ;            NAMES. If ONLY_VALID is set, the -1 values will be deleted, 
    18 ;            and a value of -1 indicates that no SELNAME has been found 
    19 ;            at all. 
     13; @param SELNAMES {in}{required} 
     14; A list of selected values 
    2015; 
    21 ; @keyword REQUIRED Normally, MAKE_SELECTION will return indexes for 
    22 ;            all values that are found, simply ignoring the selected 
    23 ;            values that are not in the NAMES array (although an error 
    24 ;            message is displayed). Set this keyword to return with 
    25 ;            -1 as soon as a selected value is not found. 
     16; @keyword ONLY_VALID 
     17; Return only indexes of found values. Values not 
     18; found are skipped. Default is to return 1 index value for 
     19; each SELNAME, which is -1 if SELNAME is not contained in 
     20; NAMES. If ONLY_VALID is set, the -1 values will be deleted, 
     21; and a value of -1 indicates that no SELNAME has been found 
     22; at all. 
    2623; 
    27 ; @keyword QUIET Suppress printing of the error message if a 
    28 ;            selected value is not found (the error condition will 
    29 ;            still be set). 
     24; @keyword REQUIRED 
     25; Normally, MAKE_SELECTION will return indexes for 
     26; all values that are found, simply ignoring the selected 
     27; values that are not in the NAMES array (although an error 
     28; message is displayed). Set this keyword to return with 
     29; -1 as soon as a selected value is not found. 
    3030; 
    31 ; @returns A (long) array with indexes to reference the selected values 
    32 ;        in the NAMES array. 
     31; @keyword QUIET 
     32; Suppress printing of the error message if a 
     33; selected value is not found (the error condition will 
     34; still be set). 
    3335; 
    34 ; @restrictions If the NAMES array contains multiple entries of the same value, 
    35 ;        only the index to the first entry will be returned. 
     36; @returns 
     37; A (long) array with indexes to reference the selected values 
     38; in the NAMES array. 
    3639; 
    37 ;        A selection can contain multiple instances of the same value. 
    38 ;        The index array will contain one entry per selected item 
    39 ;        (See example below) 
     40; @restrictions 
     41; If the NAMES array contains multiple entries of the same value, 
     42; only the index to the first entry will be returned. 
    4043; 
    41 ; @examples names = [ 'Alfred','Anton','Peter','John','Mary'] 
     44; A selection can contain multiple instances of the same value. 
     45; The index array will contain one entry per selected item 
     46; (See example below) 
     47; 
     48; @examples 
     49;           names = [ 'Alfred','Anton','Peter','John','Mary'] 
    4250;           index = MAKE_SELECTION(names,['Peter','Mary']) 
    4351;           print,index 
     
    5765;           ; prints  -1 
    5866; 
    59 ; @history mgs, 28 Aug 1998: VERSION 1.00 
    60 ;          mgs, 29 Aug 1998: - changed behavior and added ONLY_VALID keyword 
     67; @history 
     68; mgs, 28 Aug 1998: VERSION 1.00 
     69; mgs, 29 Aug 1998: - changed behavior and added ONLY_VALID keyword 
    6170; 
    62 ; @version $Id$ 
     71; @version 
     72; $Id$ 
    6373; 
    6474;- 
     
    8191  compile_opt idl2, strictarrsubs 
    8292; 
    83   
    84   
    85   
    86     ; return an index array with a number for each element in  
     93    ; return an index array with a number for each element in 
    8794    ; selnames that is found in names. 
    8895    ; Set the REQUIRED keyword to return -1 if one element is 
    89     ; not found, otherwise -1 will only be returned, if no  
     96    ; not found, otherwise -1 will only be returned, if no 
    9097    ; element is found. 
    91   
     98 
    9299    ; reset error state to 0 
    93100    message,/reset 
    94   
     101 
    95102    quiet = keyword_set(quiet) 
    96103    result = -1L 
    97   
     104 
    98105    for i=0,n_elements(selnames)-1 do begin 
    99106       test = where(names eq selnames[i]) 
    100        result = [ result, test[0] ]  
     107       result = [ result, test[0] ] 
    101108       if (test[0] lt 0) then begin 
    102109           if (keyword_set(ONLY_VALID) OR keyword_set(REQUIRED)) then $ 
     
    106113       endif 
    107114    endfor 
    108   
     115 
    109116    if (n_elements(result) gt 1) then result = result[1:*] 
    110117 
     
    114121        else result = -1L 
    115122    endif 
    116   
     123 
    117124    return,result 
    118   
     125 
    119126end 
Note: See TracChangeset for help on using the changeset viewer.