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

Last change on this file since 206 was 163, checked in by navarro, 18 years ago

header improvements : type of parameters and keywords, default values, spell checking + idldoc assistant (IDL online_help)

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