source: trunk/SRC/ToBeReviewed/STRING/delchr.pro @ 327

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

modification of some headers (+some corrections) to prepare usage of the new idldoc

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.4 KB
Line 
1;+
2;
3; @file_comments
4; Delete all occurrences of a character from a text string.
5;
6; @categories
7;
8; @param OLD {in}{required}
9; original text string.
10;
11; @param C {in}{required}
12; character to delete.
13;
14; @keyword HELP
15;
16; @returns
17; new = resulting string.
18;
19; @history
20;       R. Sterner.  5 Jul, 1988.
21;       Johns Hopkins Applied Physics Lab.
22;       RES 11 Sep, 1989 --- converted to SUN.
23;       R. Sterner, 27 Jan, 1993 --- dropped reference to array.
24;
25; Copyright (C) 1988, Johns Hopkins University/Applied Physics Laboratory
26; This software may be used, copied, or redistributed as long as it is not
27; sold and this copyright notice is reproduced on each copy made.  This
28; routine is provided as is without any express or implied warranties
29; whatsoever.  Other limitations apply as described in the file disclaimer.txt.
30;
31; @version
32; $Id$
33;
34;-
35FUNCTION delchr, old, c, HELP=hlp
36;
37  compile_opt idl2, strictarrsubs
38;
39 
40if (n_params(0) lt 2) or keyword_set(hlp) then begin
41  ras = report(['Delete all occurrences of a character from a text string.', $
42  ' new = delchr(old, char)', $
43  '   old = original text string.     in' , $
44  '   char = character to delete.     in' , $
45  '   new = resulting string.         out'])
46  return, -1
47endif
48 
49B = BYTE(OLD) ; convert string to a byte array.
50CB = BYTE(C)  ; convert char to byte.
51w = where(b ne cb[0])
52if w[0] eq -1 then return, '' ; Nothing left.
53return, string(b[w]) ; Return new string.
54END
Note: See TracBrowser for help on using the repository browser.