source: trunk/SRC/ToBeReviewed/STRING/delchr.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.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;-
35;
36FUNCTION delchr, old, c, HELP=hlp
37;
38  compile_opt idl2, strictarrsubs
39;
40 
41if (n_params(0) lt 2) or keyword_set(hlp) then begin
42  ras = report(['Delete all occurrences of a character from a text string.', $
43  ' new = delchr(old, char)', $
44  '   old = original text string.     in' , $
45  '   char = character to delete.     in' , $
46  '   new = resulting string.         out'])
47  return, -1
48endif
49 
50B = BYTE(OLD) ; convert string to a byte array.
51CB = BYTE(C)  ; convert char to byte.
52w = where(b ne cb[0])
53if w[0] eq -1 then return, '' ; Nothing left.
54return, string(b[w]) ; Return new string.
55END
Note: See TracBrowser for help on using the repository browser.