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

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

change *.pro file properties (del eof-style, del executable, set keywords Id

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