Announcement

Collapse
No announcement yet.

How to populate elements of an array in a string

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

  • How to populate elements of an array in a string

    Hi,

    I have a run time array DEPTARR which has some departments into it.
    I need to build a stirng containing these departments as running text.The message legth is 128 Chars.
    The array will have values like:
    234
    345
    357
    678
    I need to have message string built like

    Message ='Following Departments 234,345,357 678 are not in department file'.

    Any suggestions?
    BTW I am using free format.
    Thanks in advance for help.

  • #2
    Re: How to populate elements of an array in a string

    Code:
     
    if LastLoadedArrayElement > 0;
     
      If LastLoadedArrayElement = 1; 
        Message = 'Department ';
      else;
        Message = 'Departments ';
      endif;
     
      For x = 1 to LastLoadedArrayElement;
        Message += DeptArray(x)
     
        if x <> LastLoadedArrayElement;
          Message +=  ', ';
        endif;
     
      endfor;
     
      if LastLoadedArrayElement = 1;
        Message += ' is not in the department file';
      else;
        Message += ' are not in the department file';
      endif;
     
    else;
      Message = *blank;
     
    endif;
    This code assume the field "Message" is varying. Otherwise you will have to do some trimming.

    LastLoadedArrayElement field contains the last loaded array element.
    Last edited by MichaelCatalani; April 20, 2009, 05:04 PM.
    Michael Catalani
    IS Director, eCommerce & Web Development
    Acceptance Insurance Corporation
    www.AcceptanceInsurance.com
    www.ProvatoSys.com

    Comment


    • #3
      Re: How to populate elements of an array in a string

      are you using a message subfile and asking about message data?

      jamie
      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