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

Last change on this file since 236 was 232, checked in by pinsard, 17 years ago

improvements/corrections of some *.pro headers

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