ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

How to populate elements of an array in a string

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

  • jamief
    replied
    Re: How to populate elements of an array in a string

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

    jamie

    Leave a comment:


  • MichaelCatalani
    replied
    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.

    Leave a comment:


  • vinod_ksingh
    started a topic How to populate elements of an array in a string

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