Widget array-element requires constant subscript. (3565)

jmac12

Member
Hi I'm currently using open edge 10.2b I've got a variable from a database filed that is an array 99 long. I want to display all of them in a browse but i dont want to hardcode all the labels in. I’ve got the following code at the moment lots of case statements is there a way to use the closure code rather having to do 99 case statements?

define variable chrDescription as character no-undo.
define variable intLength as integer no-undo.


for each closures where closures.close-code >= 1 and closures.close-code <= 99 no-lock:

chrDescription = "Closure Code " + string(closure.close-code) + " " + closures.description.
/*message chrDescription + " " + string(intClosureCode).*/
intLength = length(chrDescription).

case closure.close-code:

when 1 then
assign
ttRecs.close-allow[closures.close-code]:column-label in browse {&browse-name} = chrDescription.
/*ttRecs.close-allow[intClosureCode]:width in browse {&browse-name} = intLength.*/
when 2 then
assign
ttRecs.close-allow[2]:label in browse {&browse-name} = chrDescription
ttRecs.close-allow[2]:width in browse {&browse-name} = intLength.
when 3 then
assign
ttRecs.close-allow[3]:label in browse {&browse-name} = chrDescription
ttRecs.close-allow[3]:width in browse {&browse-name} = intLength.
when 4 then
assign
ttRecs.close-allow[4]:label in browse {&browse-name} = chrDescription
ttRecs.close-allow[4]:width in browse {&browse-name} = intLength.



 
managed to sort it by getting the column names as a handle and going through each one of my "closure codes" Ive put the code down below incase anyone has the same issue

assign hbrCol = BRDetail:first-column in frame fmain.
repeat:
/*loop through browse columns when found a close-allow one then change label and width
of column*/
if hbrCol:name begins("close-allow") then do:

find closure where closure.close-code = intClosureCode no-lock no-error.
if avail closure then do:
chrDescription = "Closure Code " + string(closure.close-code) + " " + closures.description.
hbrCol:label = chrDescription.
hbrCol:width = length(chrDescription).
intClosureCode = intClosureCode + 1.
end.
end.

assign hbrCol = hbrCol:next-column.
if not valid-handle(hbrCol) then
leave.

end.
 
Back
Top