Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scanning and replacing character data in an array

Status
Not open for further replies.

fcsltd

IS-IT--Management
Oct 4, 2001
2
US
Hi, I have an array that is 8192A DIM(256) and it will be passed to my program containing up to 256 xml messages (via an MQ message).

Is it possible to scan the entire array at once or do I have to loop through each occurance searching for xml tags?

I have to extract a fragment of the xml based on tagname
and return it to the calling program.

I also need to remove the extracted data from the input array and return it as well. How can I concatenate the remaining data to the data before the extracted data?

thanks for any help you can provide.
M. Boyce
 
Hi,

Here is a program source template you could use :
Code:
      * Use table and not array to scan at once
     d tabxml          s           8192a   dim( 256 ) altseq(*none)
     d searcharg       s           8192a   inz('YOUR SEARCH ARGUMENT')
     d tagname         s           8192a   inz('YOUR TAGNAME')
     d returnparm      s           8192a   varying
     d fragment        s           8192a   varying
     d scanstart       s              5i 0
     d tagnamepos      s              5i 0
     d substlength     s              5i 0

     C     *Entry        Plist
     C                   Parm                    returnparm
     C                   Parm                    fragment 

      /free
       // Scan at once the entire table
       returnparm = ' ';
       if %TLOOKUP(searcharg:tabxml);
          // found entry to return to caller
          returnparm = tabxml;

          // Scan for the required tagname
          scanstart = 1; //*** ACTUALLY YOUR START SCAN POSITION
          tagnamepos = %scan( tagname: tabxml: scanstart );

          // Extract required fragment based on substlength
          // if tagname found
          if tagnamepos > 0;
             // Remaining substring length to extract the fragment
             // CHANGE TO FIT YOUR OWN NEEDS IF NECESSARY
             substlength = %len(tabxml) - tagnamepos + 1;
             fragment = %subst(tabxml:tagnamepos:substlength);
          endif;

         // Do you really need to remove & concatenate the data 
         // in the table
         // coz the next search will start from the previous found entry
         // and not from the beginning of the table ?
         // Therefore isn't it time consuming and useless procedure ?

        endif; // %Tlookup
       *inlr='1';

      /end-free
 
Thankyou for the code but in my case the returned fragment and original xml minus the fragment need to also be 8192 dim(256) to handle extracted data longer than one table element.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top