× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



%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





As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.