英文:
Change component by variable
问题
在我的公司,我设计了一些程序,用一些 FILL-INs 来显示一些信息。
他们要求使用这种方法,而不是自由格式查询,因为他们需要远程查看程序 - 而且我们已经尝试过查询了(我知道这将是最佳解决方案)。
我正在尝试对我的代码进行一些优化。所以我的问题是:是否可以通过类似这样的方式更改 FILL IN(或其他组件)的元素?
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.
因为我的当前流程类似于这样:
(如果有大约40个 FILL-INs,这将变得非常混乱)
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.
我目前使用的是版本 11.7 - 但我们将在今年晚些时候升级到 12.2。
感谢帮助!
英文:
At my company, I have a few programs that I designed to display some informations by using some FILL-INs.<br>
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:<br>
(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!
答案1
得分: 1
你不能对变量/参数等执行VALUE()操作。
但你可以遍历帧字段,并查找与你的组件名称匹配的字段(也就是遍历小部件树)。根据你的起始点(可能是父级帧),你需要首先获取字段组,然后获取该组中的字段。
ASSIGN h = h_frame:FIRST-CHILD /* 字段组 */
h = h:FIRST-CHILD. /* 孙子字段 */
DO WHILE h NE ?:
IF (h:NAME = "<your component>":u) THEN
/* 做一些操作 */ .
h = h:NEXT-SIBLING.
END.
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论