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

Last change on this file since 172 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
RevLine 
[2]1;-------------------------------------------------------------
2;+
3;
[142]4; @file_comments
[163]5; return position *array* for occurrence of a character in a string
[2]6;
[142]7; @categories
[157]8; String
[2]9;
[142]10; @param STR {in}{required}
11; the string
[2]12;
[142]13; @param SCHAR {in}{required}
14; the character to look for
[2]15;
[142]16; @returns COUNT {out}{optional}
17; The number of matches that were found
[2]18;
[142]19;  The function returns an index array similar to the
20;  result of the where function
[2]21;
[142]22; @examples
[2]23;        ind = strwhere('abcabcabc','a')
24;
25;        ; returns [ 0, 3, 6 ]
26;
[142]27; @history
[2]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;
[142]33; @version
34; $Id$
35;
[2]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
[114]50;
51  compile_opt idl2, strictarrsubs
52;
[2]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.