Kbase 21124: How To avoid error 3565 when working with array widget's elements
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  16/10/2008 |
|
Status: Unverified
GOAL:
How To avoid error 3565 when working with array widget's elements
GOAL:
Widget array-element requires constant subscript. (3565)
GOAL:
Dynamically referring to array widget elements when executing 4GL commands that include attributes and methods for those widgets.
FACT(s) (Environment):
Progress 8.x
Progress 9.x
All Supported Operating Systems
FIX:
When working with array widgets in Progress 4GL you might want to dynamically go through the elements of those widgets in order to perform some action. Using this approach, you can encounter error 3565 working with the array widget's elements. This error occurs because the expression subscripts require on-the-fly, run-time mapping of the subscripted entity to a widget.
To avoid the error, reference the handle of the array widget elements instead of trying to use widget names as references.
Example of this (full code is in below Note):
DO:
ASSIGN vhFstChildHdl = FRAME {&FRAME-NAME}:FIRST-CHILD
vhFstChildHdl = vhFstChildHdl:FIRST-CHILD.
DO viCounter = 1 TO 5:
ASSIGN vhFstChildHdl = getArrayElementHdl(vhFstChildHdl,"FILL-IN-1":U,viCounter).
IF VALID-HANDLE(vhFstChildHdl) THEN
ASSIGN vhFstChildHdl:SCREEN-VALUE = STRING(viCounter).
END.
END.
Following is the function that returns the handle of the array element:
FUNCTION getArrayElementHdl RETURNS HANDLE
(phFrameHdl AS HANDLE,
pcObjName AS CHAR,
piElement AS INT /* parameter-definitions */ ) :
/*-----------------------------------------------------------------
Purpose:
Notes:
------------------------------------------------------------------*/
DO WHILE VALID-HANDLE(phFrameHdl):
IF phFrameHdl:NAME = pcObjName AND
phFrameHdl:INDEX = piElement THEN
RETURN phFrameHdl.
ASSIGN phFrameHdl = phFrameHdl:NEXT-SIBLING.
END.
END FUNCTION.