• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

Working with multiple-selection form fields in RPGLE

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

  • Working with multiple-selection form fields in RPGLE

    In my NAB app, I have a form with a multiple-selection field that I want to read/write to via a form helper program that is written in RPGLE.

    I know that if the field is a single-selection field, I can read/write to it in my RPGLE program like this:

    vvIn_Char('MYFIELD');
    setValue('MYFIELD');


    Is there a way that I can do something similar for multiple-selection fields in RPGLE? For instance, getting the list of values from a multiple-selection field and setting a list of values to populate a multiple-selection field?




  • #2
    A multi select combo will pass down its value as usual if only one selection is made. If more than one then it will be passed down as an array of values. Here is some code to extract it.

    Code:
    lMyField = vvIn_char('MYFIELD');
    lIsMulti = (%subst(lMyField:1:1) = OB);                 // if begins with "[" it is an array
    if lIsMulti;
      lPtr   = vvJson_parse(%addr(lMyField));
      lCount = vvJsona_size(lPtr);                          // number of selections
      for lIndex=1 to lCount;
        lMyValue = %str(vvJsona_getString(lPtr:lIndex-1));  // get value of each selection
      endfor;
    endif;
    To set multiple values of a multi select combo just pass a string with a comma in between each value.

    Code:
    SetValue('MYFIELD','5,8,33');

    Comment


    • #3
      Thank you!

      Comment

      Working...
      X