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