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

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

corrections of some headers and parameters and keywords case. change of pro2href to replace proidl

  • 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
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; IDL> ind = strwhere('abcabcabc','a')
23; IDL> print, ind
24; [ 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; Copyright (C) 1998, Martin Schultz, Harvard University
36; This software is provided as is without any warranty
37; whatsoever. It may be freely used, copied or distributed
38; for non-commercial purposes. This copyright notice must be
39; kept with any copy of this software. If this software shall
40; be used commercially or sold as part of a larger package,
41; please contact the author to arrange payment.
42; Bugs and comments should be directed to mgs\@io.harvard.edu
43; with subject "IDL routine strwhere"
44;-
45;
46FUNCTION strwhere, str, schar,count
47;
48  compile_opt idl2, strictarrsubs
49;
50   if (n_elements(str) eq 0) then return,-1
51
52   ; convert to byte
53   BStr = byte(Str)
54   BSC  = (byte(schar))[0]
55
56   ; Search for matches
57   Ind = where( Bstr eq BSC, Count )
58
59   ;### bmy ### return,where(BStr eq BSC)
60   return, Ind
61
62end
Note: See TracBrowser for help on using the repository browser.