Displaying an Array Within a Frame

KMoody

Member
How can I display the contents of a dynamic array as a list within a frame?

For example, let's say the array contains "1","2","3". I want to display those values like this:

1
2
3

So far, I can only display them one at a time. I'd rather not throw those contents into a temp-table if there's a more elegant solution.

Progress: 10.2b SP7
OpenEdge Architect: 3.4.2.R342_v20090122-9I96EiWElHi8lheoJKJIvhM3JfVsYbRrgVIWL
OpenEdge OS: Windows XP Professional 2002 SP3
 

Cringer

ProgressTalk.com Moderator
Staff member
Not sure it's what you want, or if it even works as I haven't tried it, but you can do something like
do lv-i = 1 to lv-variable:extent
Is that what you need?
 

KMoody

Member
Cringer, my loop works fine. My problem is getting the entire array to display on a frame. Currently, I only know how to display the array elements one at a time.

Here's my current code:

Code:
DEF VAR array AS INTEGER EXTENT INITIAL [1,2,3].
DEF VAR lv-i AS INTEGER.
 
DO lv-i = 1 TO EXTENT(array):
    DISPLAY array[lv-i] WITH FRAME A.
END.

I can only see "3" at the end of the program.

Array1.png

I want to see the entire array without having to pause between displaying each element.

Array2.png

I know it's possible to do this with TEMP-TABLE, but I'd really like a simpler solution if it exists.

Jongpau, I'll look into the dynamic widgets.
 

Cringer

ProgressTalk.com Moderator
Staff member
Ahh ok I'm with you now. It's been a long time since I've done chui coding so I'll leave this to those who know! :)
 

LarryD

Active Member
Basically the reason it's not doing what you want is because a "DO" block does not automagically imply a down frame. However, "REPEAT" will do the down frame as long as the frame is defined as such.

One method:
Code:
DEF VAR array AS INTEGER EXTENT INITIAL [1,2,3].
DEF VAR lv-i AS INTEGER.
 
DO lv-i = 1 TO EXTENT(array):
    DISPLAY array[lv-i] WITH FRAME A DOWN.
    DOWN WITH FRAME A.
END.

or alternatively:
Code:
 DEF VAR array AS INTEGER EXTENT INITIAL [1,2,3].
DEF VAR lv-i AS INTEGER.
REPEAT lv-i = 1 TO EXTENT(array):
    DISPLAY array[lv-i] WITH FRAME A DOWN.
END.
 

KMoody

Member
Works like a charm! Thank you, Larry!

By the way, I had tried using "DOWN" in my "DO" block, but it didn't work:

Code:
DEF VAR array AS INTEGER EXTENT INITIAL [1,2,3].
DEF VAR lv-i AS INTEGER.
 
DO lv-i = 1 TO EXTENT(array):
    DISPLAY array[lv-i] WITH FRAME A DOWN.
END.

It seems that wasn't enough because it just says "FRAME A" is a "DOWN" frame. You have to add "DOWN WITH FRAME A" to tell the program to move down a line before displaying something else.

I'm not sure why you have to add "DOWN WITH FRAME A" in a "DO" loop but not in "REPEAT." Looks like I have a little more research to do. :)
 

Rob Fitzpatrick

ProgressTalk.com Sponsor
I'm not sure why you have to add "DOWN WITH FRAME A" in a "DO" loop but not in "REPEAT." Looks like I have a little more research to do. :)

REPEAT or FOR EACH implicitly makes the frame a down frame. The rules aren't quite as simple as that; I think it also has to be the innermost iterating block for this to happen.
 
Top