× 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.



Hi Scott, will this work if it is used in an OPM environment?
My calling program was generated from Advantage Plex using a generator that does not support ILE.


What do I need to do to make it callable by an OPM RPG program?

thanks for the help, I appreciate it very much!

Marilyn


From: Scott Klement <klemscot@xxxxxxxxxxxx>
Reply-To: RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>
To: RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>
Subject: Re: How to scan an entire array all at once
Date: Mon, 3 May 2004 17:03:42 -0500 (CDT)


Hi Marilyn,


[SNIP]
> The problem arises when the xml fragment I want to extract is spread between
> two array elements.
> Any ideas on an approach?


The memchr() and memcmp() functions from the ILE C runtime library can be
used to search an area of memory.  They have no idea what type of variable
they're scanning, etc, they just know that they're scanning memory.

You can use these functions in an ILE RPG program by providing the correct
prototypes.

The following is a subprocedure that I wrote for scanning memory.  (You
will have to bind your RPG program to the QC2LE binding directory.)


*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * ScanSpc(): Scan memory (or userspace) for a given string * * Space = pointer to area of memory or user space to scan * String = string to search for * SpcSize = size of space to search * * Returns 0 if nothing found, otherwise the position of the * string in the space. *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ P ScanSpc B D ScanSpc PI 10I 0 D Space * value D String 256A const varying options(*varsize) D SpcSize 10I 0 value

      * memchr(): Search memory for a character
     D memchr          PR              *   extproc('memchr')
     D   buf                           *   value
     D   chartofind                  10I 0 value
     D   bufsize                     10I 0 value

      * memcmp(): Compare two areas of memory
     D memcmp          PR            10I 0 extproc('memcmp')
     D   buf1                          *   value
     D   buf2                     65535A   const options(*varsize)
     D   size                        10I 0 value

     D                 DS
     D  Char                          1A
     D  Num                           3U 0 overlay(Char)

     D p_search        s               *
     D p_found         s               *

/free

           if (%len(String) < 1);
              return 0;
           endif;

Char = %subst(String: 1: 1);

p_search = Space;

           dou (memcmp(p_found: String: %len(String)) = 0);
               p_found = memchr(p_search: Num: SpcSize);
               if (p_found = *NULL);
                  return 0;
               endif;
               p_search = p_found + 1;
           enddo;

return (p_found - space) + 1;

      /end-free
     P                 E
_______________________________________________
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.


_________________________________________________________________
MSN Premium with Virus Guard and Firewall* from McAfee® Security : 2 months FREE* http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.