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 | |
---|
53 | function strright,s,lastn |
---|
54 | |
---|
55 | on_error,2 ; return to caller |
---|
56 | |
---|
57 | if (n_elements(s) le 0) then return,-1L |
---|
58 | |
---|
59 | l = strlen(s) |
---|
60 | |
---|
61 | if (n_elements(lastn) le 0) then lastn = 1 |
---|
62 | if lastn gt l then lastn = l |
---|
63 | |
---|
64 | result = strmid(s,l-lastn,l) |
---|
65 | |
---|
66 | return,result |
---|
67 | end |
---|