source: trunk/SRC/ToBeReviewed/STRING/strright.pro

Last change on this file was 495, checked in by pinsard, 10 years ago

fix thanks to coding rules; typo; dupe empty lines; trailing blanks

  • 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; return right subportion from a string
5;
6; @categories
7; String
8;
9; @param S {in}{required}
10; the string to be searched
11;
12; @param LASTN {in}{required}{default=1}
13; the number of characters to be returned.
14;
15; If LASTN is the strlen(STRING), the complete string
16; is returned.
17;
18; @returns
19; The portion of LASTN characters of S counted from the back.
20;
21; @examples
22;
23; add a "/" in to path if it "/" is not at the end :
24;
25;  IDL> path="/tmp"
26;  IDL> if (strright(path) ne '/') then path = path + '/'
27;  IDL> print,path
28;  /tmp/
29;
30; @history
31;        mgs, 19 Nov 1997: VERSION 1.00
32;
33; @version
34; $Id$
35;
36; Copyright (C) 1997, Martin Schultz, Harvard University
37; This software is provided as is without any warranty
38; whatsoever. It may be freely used, copied or distributed
39; for non-commercial purposes. This copyright notice must be
40; kept with any copy of this software. If this software shall
41; be used commercially or sold as part of a larger package,
42; please contact the author to arrange payment.
43; Bugs and comments should be directed to mgs\@io.harvard.edu
44; with subject "IDL routine strright"
45;-
46FUNCTION strright, s, lastn
47;
48  compile_opt idl2, strictarrsubs
49;
50
51    on_error,2   ; return to caller
52
53    if (n_elements(s) le 0) then return,-1L
54
55    l = strlen(s)
56
57    if (n_elements(lastn) le 0) then lastn = 1
58    if lastn gt l then lastn = l
59
60    result = strmid(s,l-lastn,l)
61
62    return,result
63end
Note: See TracBrowser for help on using the repository browser.