ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Array Processing

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Array Processing

    I had to increase my buffer in my mq program to 16MGs. When I did this my message is spread over 255 buffer arrays.

    For example

    Each buffer holds 1024 characters. The last line of characters of buffer 1 are like this.
    BUFFER(1)
    961 '2E000000000{20070709000000003XXX '
    1021 '2007'
    BUFFER(2) =
    ....5...10...15...20...25...30...35...40...45...50 ...55...60
    1 '00{20070712000000003XXX 200710031'
    61 '02490032802260890 IN000002334I000000000{200707120000000'
    121 '03XXX 20071003102490032822034590 '
    181 ' IN000003607D000000000{20070712000000003XXX '
    241 ' 20071003102490032867040590 IN000004621A0'

    You will notice that the message is spread over the buffers. I need to create a process that will read all of the buffers and capture the message.

    Has anyone accomplished this?

    DAC

  • #2
    Re: Array Processing

    Clarification please. Are the terms buffers just the names of arrays or do they have a specific meaning?

    Do you know how many elements are filled in the Buffer()?

    For Start = 1 to MyLastIndex;
    'Put the Buffer(Start) some place
    EndFor;



    Am i way off?
    Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

    Comment


    • #3
      Re: Array Processing

      %elem will give you elements also...but somehow I dont think this is your issue.

      please explain a bit more.


      Code:
            * --------------------------------------------------
            * Program - ARRAY01
            * Purpose - arrays examples
            * Written -
            * Author  -
            *
            * PROGRAM DESCRIPTION
            *   work with arrays
            *
            *
            * INPUT PARAMETERS
            *   Description        Type  Size    How Used
            *   -----------        ----  ----    --------
            *   InMessage#               15  5
            *   Indynamic                 1
            *   InNoDups                  1
            *
            *
            *
            * INDICATOR USAGE
            *   xx - xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
            *---------------------------------------------------
      
           d ARRAY01         PR                  extpgm('ARRAY01')
           d   InMessage#                  15  5
           d   Indynamic                    1
           d   InNoDups                     1
      
           d ARRAY01         PI
           d   InMessage#                  15  5
           d   Indynamic                    1
           d   InNoDups                     1
            *
            * Procedure calls
            *
           d $Command        pr                  EXTPGM('QCMDEXC')
           d  CmdString                   256
           d  CmdLength                    15  5
      
      
           d #Loaded         s             10i 0
           d #Random         s             10i 0
           d ArrayLine       s             10    Dim(50)
           d AX              s             04  0
           d CmdLength       s             15  5
           d CmdString       s            256
           d count           s              3  0
           d count2          s              3  0
           d data            s             40
           d lastchar        s              1
           d letters         c                   CONST('AEIOUBCDFGHJKLMNPQRSTVWXYZ')
           d numbers         c                   CONST('0123456789')
           d nx1             s              3  0
           d nx2             s              3  0
           d msg#            s              3  0
           d outmessage      s             40
           d random          s              2  0
           d reply           s             01
      
           dfilefbk          ds
           d FileRRN               397    400I 0
      
           d message         s             40    DIM(05) CTDATA PERRCD(1)
      
           d                 ds
           d dyno1                         40a   Dim(5) Ascend
           d  First10                      10a   Overlay(dyno1)
           d  Second10                     10a   Overlay(dyno1:*Next)
           d  Third10                      10a   Overlay(dyno1:*Next)
           d  Fourth10                     10a   Overlay(dyno1:*Next)
      
           d dyno2                          1  0 Dim(5)
      
           d Nodups                         1  0 Dim(100)
            /free
      
                // look at parameters to tell what to do
      
              select;
                when %parms >= 3;
                //exsr $lookup;
                when %parms >= 2;
                  exsr $dynamic;
                when %parms >= 1;
                  exsr $messages;
              endsl;
      
      
                *inlr = *on;
      
             //=========================================
             //  $message - use compile time array
             //=========================================
      
               begsr $messages;
      
                 msg# = inmessage#;
                   monitor;
                     outmessage = message(msg#);
                     dsply outmessage reply;
                   on-error;
                     dsply 'Invalid message #'  reply;
                   endmon;
      
               endsr;
      
             //=========================================
             //  $dynamic - use dynamic array
             //=========================================
      
               begsr $dynamic;
                 #random = 26;
                 for count = 1 to %elem(dyno1);
      
                   clear data;
                   dou %len(%trim(data)) = 40;
      
                     dou random <> *zeros;
                       exsr $getRandom;
                     enddo;
      
                     lastchar = %subst(letters:Random:1);
                     data = %trim(data) + lastchar;
                   enddo;
                   dyno1(count) = data;
                 endfor;
      
                   // when sorting array #loaded = number of elements in array.
                   // sort entire array dyno1 by the second10 characters.
                   // this would be great for ..sorting a subfile.
      
      
                // %elem will give you all the elements in the array
                // this would include the blank ones.
      
                 #loaded = %elem(dyno1);
      
                 SortA %SubArr(second10:1:#Loaded);
                   for count = 1 to #loaded;
                     dsply second10(count) reply;
                   endfor;
      
      
                 //example of %xfoot
      
                 #random = 10;
                 for count = 1 to #loaded;
      
                   dou random <> *zeros;
                     exsr $getRandom;
                   enddo;
      
                   dyno2(count) = random;
      
                 endfor;
      
                   clear outmessage;
                   for count2= 1 to #loaded;
                     outmessage = %trim(outmessage) +
                                  %editc(dyno2(count2):'X');
                     if count2 > 0 and count2 < 5;
                     outmessage = %trim(outmessage) + '@+@';
                     endif;
      
                   endfor;
                   outmessage = %trim(outmessage) +  '@=@'  +
                                %editc(%xfoot(dyno2):'X');
                   outmessage = %xlate('@' : ' ': outmessage);
      
                 dsply outmessage reply;
      
               endsr;
      
      
             //=========================================
             //  $nodups - no duplicates in array
             //=========================================
      
               begsr $nodups;
      
                 #random = 10;
                 for count = 1 to 100;
      
      
                     dou random <> *zeros;
                       exsr $getRandom;
                     enddo;
      
                   dyno1(count) = data;
                 endfor;
      
               endsr;
      
             //=========================================
             // $getRandom - Generate random number
             //=========================================
      
                   begsr $getRandom;
      
                        clear  Random;
            /end-free
      
           c/Exec SQL
           c+ Select Rand() * :#random Into :Random
           c+ From SYSIBM/SYSDUMMY1
           c/End-Exec
      
            /free
      
      
                   endsr;
      
      
             //=========================================
             //  *inzsr - Initial one time subroutine
             //=========================================
      
               begsr *inzsr;
      
      
               cmdstring = 'addlible jamielib *last';
               cmdlength = %len(%trim(cmdstring));
               monitor;
                $command(cmdstring : cmdlength);
               on-error;
                dsply 'Library error!'     reply;
               endmon;
      
               endsr;
      
            /end-free
      
      ** messages                            >*
         This is message #1                   1
         This is message #2                   2
         This is message #3                   3
         This is message #4                   4
         This is message #5                   5
      All my answers were extracted from the "Big Dummy's Guide to the As400"
      and I take no responsibility for any of them.

      www.code400.com

      Comment

      Working...
      X