|
If the substring needs to be contained entirely in an array element you'll have to do the storage mapping stuff for the first and last character in the substring or use %scan in a loop. If the substring can occur more than once you'll have to use %scan in a loop. > -----Original Message----- > From: rpg400-l-bounces@xxxxxxxxxxxx > [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of rob@xxxxxxxxx > Sent: Thursday, April 21, 2005 11:48 AM > To: RPG programming on the AS400 / iSeries > Subject: Re: Array Lookup in ILERPG ? > > 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.langre > f.doc/c0925085641.htm#HDRBBLOO > > > > > If you use stone knives and bearskins try: > > > http://publib.boulder.ibm.com/infocenter/iseries/v5r3/ic2924/b > ooks/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. > > > -- > 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. > > ***************************** NOTICE: All e-mail sent to or from this e-mail address will be received or otherwise recorded by The Sharper Image corporate e-mail system and is subject to archival, monitoring, and review by and/or disclosure to Sharper Image security and other management. This message is intended only for the use of the addressee and may contain information that is privileged and confidential. The contents of this message may contain personal views which are not the views of The Sharper Image. If you are not the intended recipient, dissemination of this communication is prohibited. *****************************
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.