source: trunk/SRC/ToBeReviewed/STRING/strwhere.pro @ 232

Last change on this file since 232 was 232, checked in by pinsard, 17 years ago

improvements/corrections of some *.pro headers

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.5 KB
Line 
1;+
2;
3; @file_comments
4; return position *array* for occurrence of a character in a string
5;
6; @categories
7; String
8;
9; @param STR {in}{required}
10; the string
11;
12; @param SCHAR {in}{required}
13; the character to look for
14;
15; @returns COUNT {out}{optional}
16; The number of matches that were found
17;
18;  The function returns an index array similar to the
19;  result of the where function
20;
21; @examples
22;        ind = strwhere('abcabcabc','a')
23;
24;        ; returns [ 0, 3, 6 ]
25;
26; @history
27;        mgs, 02 Jun 1998: VERSION 1.00
28;        bmy, 30 Jun 1998: - now returns COUNT, the number
29;                            of matches that are found (this is
30;                            analogous to the WHERE command)
31;
32; @version
33; $Id$
34;
35;-
36; Copyright (C) 1998, Martin Schultz, Harvard University
37; This software is provided as is without any warranty
38; whatsoever. It may be freely used, copied or distributed
39; for non-commercial purposes. This copyright notice must be
40; kept with any copy of this software. If this software shall
41; be used commercially or sold as part of a larger package,
42; please contact the author to arrange payment.
43; Bugs and comments should be directed to mgs@io.harvard.edu
44; with subject "IDL routine strwhere"
45;
46function strwhere,str,schar,Count
47;
48  compile_opt idl2, strictarrsubs
49;
50 
51 
52   if (n_elements(str) eq 0) then return,-1
53 
54   ; convert to byte
55   BStr = byte(Str)
56   BSC  = (byte(schar))[0]
57 
58   ; Search for matches
59   Ind = where( Bstr eq BSC, Count )
60
61   ;### bmy ### return,where(BStr eq BSC)
62   return, Ind
63
64end
65   
Note: See TracBrowser for help on using the repository browser.