;+ ; ; @file_comments ; return position *array* for occurrence of a character in a string ; ; @categories ; String ; ; @param STR {in}{required} ; the string ; ; @param SCHAR {in}{required} ; the character to look for ; ; @returns COUNT {out}{optional} ; The number of matches that were found ; ; The function returns an index array similar to the ; result of the where function ; ; @examples ; ind = strwhere('abcabcabc','a') ; ; ; returns [ 0, 3, 6 ] ; ; @history ; mgs, 02 Jun 1998: VERSION 1.00 ; bmy, 30 Jun 1998: - now returns COUNT, the number ; of matches that are found (this is ; analogous to the WHERE command) ; ; @version ; $Id$ ; ;- ; Copyright (C) 1998, Martin Schultz, Harvard University ; This software is provided as is without any warranty ; whatsoever. It may be freely used, copied or distributed ; for non-commercial purposes. This copyright notice must be ; kept with any copy of this software. If this software shall ; be used commercially or sold as part of a larger package, ; please contact the author to arrange payment. ; Bugs and comments should be directed to mgs@io.harvard.edu ; with subject "IDL routine strwhere" ; function strwhere,str,schar,Count ; compile_opt idl2, strictarrsubs ; if (n_elements(str) eq 0) then return,-1 ; convert to byte BStr = byte(Str) BSC = (byte(schar))[0] ; Search for matches Ind = where( Bstr eq BSC, Count ) ;### bmy ### return,where(BStr eq BSC) return, Ind end