|
Hey Scott, thanks for that good tip! Yes, I used some recommendations but I am
also new to procedures so I will try this one too.
Thanks!
Peter Vidal
Programmer Analyst
PALL Aeropower Corp.
Scott Klement
<klemscot@klement To: rpg400-l@midrange.com
s.com> cc:
Sent by: Subject: Re: Find the
rightmost character
rpg400-l-admin@mi ('/') on an address link
drange.com
02/05/2002 05:18
PM
Please respond to
rpg400-l
On Tue, 5 Feb 2002 Peter_Vidal@pall.com wrote:
>
> For example, I have a link like this:
> NPR-SERVER-NT/SCANNING/Common/Steve%20Maher/EAR90881/AC9012F1240Y6.B.HPGL
>
> I need to just get the file name only. However, I am trying to use the CHECKR
I realize that you've already solved this... (it's a pretty common
thing to need to do, so I imagine many people have or will give you
solutions)
But, here's a slightly more efficient method. Rather than scanning the
string several times to find all the slashes, it uses the C "strrchr"
function which scans for a single character, starting at the end of
the string... since it only scans the string once, it'll run slightly
faster...
H DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('QC2LE')
D basename PR 256A
D path 256A const
D my_file S 50A
D my_path S 256A
c eval my_path = '/NPR-SERVER-NT/SCANNING/' +
c 'Common/Steve%20Maher/' +
c 'EAR90881/AC9012F1240Y6.B.HPGL'
c eval my_file = basename(my_path)
c dsply my_file
c eval *inlr = *on
P basename B
D basename PI 256A
D path 256A const
d strrchr PR * extproc('strrchr')
d wholestr * value options(*string)
d char 10I 0 value
D SLASH c const(97)
D p S *
c eval p = strrchr(path: SLASH)
c if p = *NULL
c return *blanks
c else
c eval p = p + 1
c return %str(p)
c endif
P E
_______________________________________________
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@midrange.com
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l
or email: RPG400-L-request@midrange.com
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.