P
Patrick Tingen
Guest
The easiest way in this case would be to combine the triggers and use a generic name, like this: ON LEAVE OF proc-1 IN FRAME f-main , proc-2 IN FRAME f-main , proc-3 IN FRAME f-main DO: DEFINE VARIABLE hProcName AS HANDLE NO-UNDO. CASE self:name: WHEN 'proc-1' THEN hProcName = hProcName-1:HANDLE. WHEN 'proc-2' THEN hProcName = hProcName-2:HANDLE. WHEN 'proc-3' THEN hProcName = hProcName-3:HANDLE. END CASE. hProcName:SCREEN-VALUE = getProcName(1, SELF:SCREEN-VALUE). END. An alternative would be to define an array and assign the appropriate handles of the fields to that on startup of the program. Then do some fiddling with the SELF:NAME to find out which element you need: /* Startup */ DEFINE VARIABLE hProc AS HANDLE EXTENT 5. DO WITH FRAME f-main: hProc[1] = hProcName-1:HANDLE. hProc[2] = hProcName-2:HANDLE. hProc[3] = hProcName-3:HANDLE. END. ON LEAVE OF proc-1 IN FRAME f-main , proc-2 IN FRAME f-main , proc-3 IN FRAME f-main DO: DEFINE VARIABLE i AS INTEGER NO-UNDO. i = INTEGER(ENTRY(2,SELF:NAME,'-')). hProc:SCREEN-VALUE = getProcName(1, SELF:SCREEN-VALUE). END. Even fancier would be to define a function that you pass the name of the widget and which will walk the widget tree of the window to find that widget and return its handle. But beware, because it will add a lot of overhead, although on modern hardware this will probably not even be noticable. FUNCTION getWidgetHandle RETURNS HANDLE ( pcWidgetName AS CHARACTER ) : DEFINE VARIABLE hWidget AS HANDLE NO-UNDO. hWidget = FRAME {&FRAME-NAME}:FIRST-CHILD:FIRST-CHILD. REPEAT WHILE VALID-HANDLE(hWidget): IF hWidget:NAME = pcWidgetName THEN RETURN hWidget. hWidget = hWidget:NEXT-SIBLING. END. RETURN ?. END FUNCTION. /* getWidgetHandle */ ON LEAVE OF proc-1 IN FRAME f-main , proc-2 IN FRAME f-main , proc-3 IN FRAME f-main DO: getWidgetHandle( REPLACE(SELF:NAME,'proc-', 'procName-')):SCREEN-VALUE = getProcName(1, SELF:SCREEN-VALUE). END.
Continue reading...
Continue reading...