|
Interesting code. You could also have issues if the string being scanned for begins in one array element and finishes in the next. Rob Berendt -- Group Dekko Services, LLC Dept 01.073 PO Box 2000 Dock 108 6928N 400E Kendallville, IN 46755 http://www.dekko.com Keith E Smith <keith@xxxxxxxxxx> Sent by: rpg400-l-bounces+rob=dekko.com@xxxxxxxxxxxx 04/21/2005 12:41 PM Please respond to RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx> To RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>, luqman@xxxxxxxxxxxxxxxx cc Subject Re: Array Lookup in ILERPG ? %lookup is fine for a whole item match. My docs don't show a way to look for a particular string anywhere in the array. They could be out of date. Assuming you didn't mean whole string match or gt/lt matches and you are looking for a needle anywhere in the haystack, you could use a pointer ala: *!rpgle Dmyar s 80a dim(50) Dmyar_ptr s * inz(%addr(myar)) Dmyar_string s 4000a based(myar_ptr) . . . /free pos = %scan("something":myar_string); if pos > 0; ar_ix = %int(pos/80); ar_ixpos = %fpt(pos/80); endif; . . . Would yeild the array element in ar_ix and the position within that element in ar_ixpos. This could be trivially put in a function/procedure, but I'm not sure what it would buy you over a loop, unless you were just looking to see if it is there ie, myar is a text message and you are just checking to see if a particular word is in there anywhere: if %scan("badword":myar_string); exsr abort_send; endif; --Keith rob@xxxxxxxxx wrote: > If you use WDSC try: > http://127.0.0.1:4126/help/topic/com.ibm.etools.iseries.langref.doc/c0925085641.htm#HDRBBLOO > > If you use stone knives and bearskins try: > http://publib.boulder.ibm.com/infocenter/iseries/v5r3/ic2924/books/c092508429.htm#HDRBBLOO > > Rob Berendt ===== > Is there any function to search for string in an Array in ILERPG, instead > of > using loops ? > > Best Regards, > > Luqman > > > > -- This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx 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-2024 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.