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

Last change on this file since 114 was 114, checked in by smasson, 18 years ago

new compilation options (compile_opt idl2, strictarrsubs) in each routine

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.6 KB
Line 
1; $Id$
2;-------------------------------------------------------------
3;+
4; NAME:
5;        STRRIGHT
6;
7; PURPOSE:
8;        return right subportion from a string
9;
10; CATEGORY:
11;        string handling
12;
13; CALLING SEQUENCE:
14;        res = STRRIGHT(string [,nlast])
15;
16; INPUTS:
17;        STRING --> the string to be searched
18;
19;        NLAST --> the number of characters to be returned. Default
20;           is 1. If NLAST is ge strlen(STRING), the complete string
21;           is returned.
22;
23; KEYWORD PARAMETERS:
24;
25; OUTPUTS:
26;        The portion of NLAST characters of STRING counted from the back.
27;
28; SUBROUTINES:
29;
30; REQUIREMENTS:
31;
32; NOTES:
33;
34; EXAMPLE:
35;        if (strright(path) ne '/') then path = path + '/'
36;
37; MODIFICATION HISTORY:
38;        mgs, 19 Nov 1997: VERSION 1.00
39;
40;-
41; Copyright (C) 1997, Martin Schultz, Harvard University
42; This software is provided as is without any warranty
43; whatsoever. It may be freely used, copied or distributed
44; for non-commercial purposes. This copyright notice must be
45; kept with any copy of this software. If this software shall
46; be used commercially or sold as part of a larger package,
47; please contact the author to arrange payment.
48; Bugs and comments should be directed to mgs@io.harvard.edu
49; with subject "IDL routine strright"
50;-------------------------------------------------------------
51
52
53function strright,s,lastn
54;
55  compile_opt idl2, strictarrsubs
56;
57 
58    on_error,2   ; return to caller
59 
60    if (n_elements(s) le 0) then return,-1L
61 
62    l = strlen(s)
63 
64    if (n_elements(lastn) le 0) then lastn = 1
65    if lastn gt l then lastn = l
66 
67    result = strmid(s,l-lastn,l)
68 
69    return,result
70end
Note: See TracBrowser for help on using the repository browser.