Display statement with when option

Kalan

Member
Greetings,

Is there any way to avoid blank line on the below example pls?

┌List Of Lines┐
│Text1
│Text2

│Text4
│Text5
└───────┘

def var lv_flag as logical no-undo init no.
lv_flag = no.

Disp 'Text1' skip
'Text2' skip
'Text3' when lv_flag skip
'Text4' skip
'Text5' skip
with fram frdisp
ROW 2 COLUMN 3 WITH SIDE-LABEL WITH NO-LABEL TITLE "List Of Lines".
 

Osborne

Active Member
This is one possible solution:
Code:
DEFINE VARIABLE vCount AS INTEGER NO-UNDO.
DEFINE VARIABLE vLine AS INTEGER NO-UNDO.
DEFINE VARIABLE vText AS CHARACTER EXTENT 5 NO-UNDO.
def var lv_flag as logical no-undo init no.

FORM
    vText[1] skip
    vText[2] skip
    vText[3] skip
    vText[4] skip
    vText[5] skip
    with FRAME frdisp
         ROW 2 COLUMN 3 NO-LABELS TITLE "List Of Lines".

DO vCount = 1 TO 5:
    IF vCount <> 3 OR
       vCount = 3 AND lv_flag THEN DO:
       vLine = vLine + 1.
       DISPLAY 'Text' + STRING(vCount) @ vText[vLine] WITH FRAME frdisp.
    END.
END.
 

Rob Fitzpatrick

ProgressTalk.com Sponsor
The frame has to be laid out with a line for 'Text3' because, based on the display statement, it could be displayed.

Another option is to put the things you may want to display in a temp-table, query it to get the set of data you want, and output the results of that query.
 

Kalan

Member
@Osborne/Rob, Excellent, it works by following the form line position with array strings. I was bit hesitant to keep this in temp table and display that in read only browser.
 

Rob Fitzpatrick

ProgressTalk.com Sponsor
I was bit hesitant to keep this in temp table and display that in read only browser.

It doesn't have to be too complicated. Here is a simple example:
Code:
define variable i as integer no-undo.

define temp-table ttStuff no-undo
  field MyText      as character
  field IsDisplayed as logical initial true
  index MyText        is unique Mytext
  index DisplayedText is unique IsDisplayed MyText
.

// business logic goes here to populate the table, e.g.:
do i = 1 to 5:
  create ttStuff.
  ttStuff.MyText = "Text" + string( i ).
end.

// business logic goes here to determine if Text3 is special and should be hidden, e.g.:
find ttStuff where ttStuff.MyText = "Text3".
if available( ttStuff ) then
  ttStuff.IsDisplayed = false.

// output
// in this case, a simple FOR/DISPLAY, but could also be a dynamic query/browse
for each ttStuff where ttStuff.IsDisplayed:
  display ttStuff.MyText.
end.

Also, having re-read your original post and comparing it with your reply, I'm now confused about your requirement. Your initial post was about the gap in an implicit frame with DISPLAY... WHEN; it wasn't about a browse.

Can you post some actual code that illustrates what you're attempting to do and what your issue is?
 

Kalan

Member
Thanks a lot Rob, you're right. In the existing code, display statement appears with 5 lines of string constant values. i.e. Text1, Text2... Text5. My requirement to add one more Text line in between those 5 lines. For this when we use WHEN option (i.e. Display Text1 SKIP Text2 SKIP Text3 when the flag is ON SKIP Text4 Text5 Text 6) the blank line appears on screen buffer when flag is off. After seeing your reply I understand we can keep this in temp-table and display it using For Each instead of the browser. Cheers.
 
Top