Search code examples
openedgeprogress-4gl

Change component by variable


At my company, I have a few programs that I designed to display some informations by using some FILL-INs.

They asked to do this instead of a Freeform Query, because they need to see the program from far away - And we already tried the Query (This would be the best solution, I know).

I'm trying to make some optimizations into my code. So my question is: Is it possible to change elements of FILL IN (or other components) by using something like this?

DEFINE INPUT PARAMETER cComponent AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER cMessage   AS CHARACTER NO-UNDO.

VALUE(cComponent):SCREEN-VALUE IN FRAME {&FRAME-NAME} = cMessage.

Because my current flow is something like this:
(And if you have something like 40 FILL-INs, this becomes a great mess to work with)

DEFINE INPUT PARAMETER iID      AS INTEGER   NO-UNDO.
DEFINE INPUT PARAMETER cMessage AS CHARACTER NO-UNDO.

CASE iID:

    WHEN 1 THEN DO:
        ASSIGN fll-info1:SCREEN-VALUE = cMessage.
        ...
    END.

    ...

    WHEN n THEN DO:
        ASSIGN fll-infon:SCREEN-VALUE = cMessage.
        ...
    END.

END CASE.

I'm currently using version 11.7 - But we'll start upgrading to 12.2 later this year.

Thanks for the help!


Solution

  • You can't do a VALUE() for variables/parameters/etc.

    But what you can do is loop through the frame fields, and look for a field that matches your component name (aka walking the widget-tree). Depending on what your starting point is (the parent frame, probable), you will need to get the field group first, then the fields in that group.

    ASSIGN h = h_frame:FIRST-CHILD        /* The Field Group */
           h = h:FIRST-CHILD.                  /* The grandchild */
    DO WHILE h NE ?:            
    
      IF (h:NAME = "<your component>":u) THEN
        /* do something */ .
    
      h = h:NEXT-SIBLING.
    END.