source: trunk/SRC/ToBeReviewed/STRING/delchr.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.7 KB
Line 
1;-------------------------------------------------------------
2;+
3; NAME:
4;       DELCHR
5; PURPOSE:
6;       Delete all occurrences of a character from a text string.
7; CATEGORY:
8; CALLING SEQUENCE:
9;       new = delchr(old, char)
10; INPUTS:
11;       old = original text string.     in
12;       char = character to delete.     in
13; KEYWORD PARAMETERS:
14; OUTPUTS:
15;       new = resulting string.         out
16; COMMON BLOCKS:
17; NOTES:
18; MODIFICATION HISTORY:
19;       R. Sterner.  5 Jul, 1988.
20;       Johns Hopkins Applied Physics Lab.
21;       RES 11 Sep, 1989 --- converted to SUN.
22;       R. Sterner, 27 Jan, 1993 --- dropped reference to array.
23;
24; Copyright (C) 1988, Johns Hopkins University/Applied Physics Laboratory
25; This software may be used, copied, or redistributed as long as it is not
26; sold and this copyright notice is reproduced on each copy made.  This
27; routine is provided as is without any express or implied warranties
28; whatsoever.  Other limitations apply as described in the file disclaimer.txt.
29;-
30;-------------------------------------------------------------
31 
32        FUNCTION DELCHR, OLD, C, help=hlp
33;
34  compile_opt idl2, strictarrsubs
35;
36 
37        if (n_params(0) lt 2) or keyword_set(hlp) then begin
38          print,' Delete all occurrences of a character from a text string.'
39          print,' new = delchr(old, char)'
40          print,'   old = original text string.     in'
41          print,'   char = character to delete.     in'
42          print,'   new = resulting string.         out'
43          return, -1
44        endif
45 
46        B = BYTE(OLD)                      ; convert string to a byte array.
47        CB = BYTE(C)                       ; convert char to byte.
48        w = where(b ne cb[0])
49        if w[0] eq -1 then return, ''      ; Nothing left.
50        return, string(b[w])               ; Return new string.
51        END
Note: See TracBrowser for help on using the repository browser.