Question Can we remove the space allocated for a table field in a frame when the field values is empty in CHUI?

Rajendran_

New Member
Hello everyone,

I have table with certain number of fields, let's say for example 7 fields. My 7th field would have value for some records and would be empty for some records. I created a simple frame with a particular width that fits the first 6 fields and the 7th field is displayed on the second line of the record. Something like below
___________________________________
Fld1. Fld2. Fld3. Fld4. Fld5. Fld6.
Fld7
___________________________________
Fv1. Fv2. Fv3. Fv4. Fv5. Fv6.
Fv7.
...
...
Fv1. Fv2. Fv3. Fv4. Fv5. Fv6.
Fv7.

If the 7th field value is empty, i don't want the empty space between the current and the next record. I want it to be displayed something like below.

Fv1. Fv2. Fv3. Fv4. Fv5. Fv6.
Fv1. Fv2. Fv3. Fv4. Fv5. Fv6.
Fv7.

Is there a way that we can remove the space allocated for that 7th field for one record and add the space for another record if necessary??

Thanks in advance!
 

TomBascom

Curmudgeon
Is your issue that you have an unwanted blank line because the fields do not all fit on a single line?
 

Rajendran_

New Member
Hello Tom,
Yes, I'm using a frame width which should not be extended more. So the field label and it's value are wrapping to the second line. I'm just thinking if there would a way to remove the space allocation for a field in a frame for particular record or if there is any hack code that I can do to display without space. Thank you for you quick response Tom. Hope you could help me on this and if we couldn't do that can you please elaborate to me.

Thanks you!
 

tamhas

ProgressTalk.com Sponsor
You don't say how you are doing the display, but if it is something like a loop with a display, then do one display of the first 6 and then test for non-null before displaying the 7th. This will, of course, require appropriate verbs for display that will allow you to keep control.
 

Rajendran_

New Member
Hi Tamhas,

The display is inside a for loop, Yes I tried that by displaying the first 6 items in with one display statement and checked if the 7th field is not null and then displayed it with a second display. It doesn't works for me since I'm using the same frame.

I just created this same code below. If we run it I'm getting a blank line where cs-cmnt is blank, which is what I don't what


Code:
define temp-table customer
field cs-id as character format "x(5)"
field cs-name as character format "x(20)"
field cs-status as logical format "Yes/No"
field cs-ind1 as character format "x(10)"
field cs-ind2 as character format "x(10)"
field cs-ind3 as character format "x(10)"
field cs-cmnt as character format "x(40)".

define variable iCnt as integer no-undo .

repeat iCnt = 1 to 10:
create customer.
assign
cs-id = "Cust" + string(iCnt)
cs-name = "Cust Name" + string(iCnt)
cs-status = yes
cs-ind1 = "Indicator1." + string(iCnt)
cs-ind2 = "Indicator2." + string(iCnt)
cs-ind3 = "Indicator3." + string(iCnt)
cs-cmnt = if (iCnt modulo 2) = 0  then "This comment has a value for cust " + cs-id else "".
end.

define frame a
cs-id cs-name cs-name cs-status cs-ind1 cs-ind2 cs-ind3 cs-cmnt
with down width 72.

for each customer :
display cs-id  cs-name cs-status cs-ind1 cs-ind2 cs-ind3 with frame a .
if trim(cs-cmnt) <> "" then display cs-cmnt with frame a.
end.


OUTPUT:
┌──────────────────────────────────────────────────────────────────────┐
│cs-id cs-name cs-status cs-ind1 cs-ind2 cs-ind3 │
│cs-cmnt │
│──────────────────────────────────────────────────────────────────────│
│Cust1 Cust Name1 Yes Indicator1 Indicator2 Indicator3 │
│ │ /* I DON'T WANT THIS LINE IF CS-CMNT IS BLANK */
│Cust2 Cust Name2 Yes Indicator1 Indicator2 Indicator3 │
│This comment has a value for cust Cust2 │
│Cust3 Cust Name3 Yes Indicator1 Indicator2 Indicator3 │
│ │
│Cust4 Cust Name4 Yes Indicator1 Indicator2 Indicator3 │
│This comment has a value for cust Cust4 │
│Cust5 Cust Name5 Yes Indicator1 Indicator2 Indicator3 │
│ │
│Cust6 Cust Name6 Yes Indicator1 Indicator2 Indicator3 │
│This comment has a value for cust Cust6 │
│Cust7 Cust Name7 Yes Indicator1 Indicator2 Indicator3 │
│ │
│Cust8 Cust Name8 Yes Indicator1 Indicator2 Indicator3 │
│This comment has a value for cust Cust8 │
│Cust9 Cust Name9 Yes Indicator1 Indicator2 Indicator3 │
│ │
│Cust1 Cust Name10 Yes Indicator1 Indicator2 Indicator3 │
│This comment has a value for cust Cust10 │
└──────────────────────────────────────────────────────────────────────┘
 
Last edited:

Rajendran_

New Member
Reread my second sentence and look up PUT.
Can you please explain me in more detail please? I don't want that blank line if, field7 is blank. Display the field 7 in 2nd line of record row only if it has a value.

I want to display it like

cs-id cs-name ..... cs-ind3
cs-cmnt
cs-id cs-name ..... cs-ind3 --> for this record the cs-cmnt is blank so the blank line is not displayed
cs-id cs-name ..... cs-ind3
cs-cmnt
 
Last edited:

Rajendran_

New Member
Is your issue that you have an unwanted blank line because the fields do not all fit on a single line?
Hi Tom, It's not an unwanted blank line. I'm displaying the record in 2 line, where the first 6 fields are on first line and 7th field on 2nd line. But when the last field(7th field) value is blank I don't want that blank line to be displayed. I tried using put and FRAME [FRAME_NAME]:LINE to put the line on required rows but it's not working as expected.

--
Thanks
 

TomBascom

Curmudgeon
The layout for a FRAME is fixed once you "realize" it. So, no, you cannot have some fields be skipped when they are blank.

At least not directly.

It's a horrible kludge but... you could have a two-step, indirect process that gets the job done. Something along these lines:

Code:
define variable dummyLine as character no-undo format "x(60)".

form
  dummyLine skip
 with
  frame fake
  down
.

for each customer no-lock:
  /* display custNum name discount. */
  dummyLine = substitute( "&1 &2", string( custNum, ">>>>>>>9" ), name ).
  display dummyLine with frame fake.
  down with frame fake.
  if discount > 0 then
    do:
      dummyLine = string( discount, ">>9.99%" ).
      display dummyLine with frame fake.
      down with frame fake.
    end.
end.
 
Hi Tamhas,

The display is inside a for loop, Yes I tried that by displaying the first 6 items in with one display statement and checked if the 7th field is not null and then displayed it with a second display. It doesn't works for me since I'm using the same frame.

I just created this same code below. If we run it I'm getting a blank line where cs-cmnt is blank, which is what I don't what


Code:
define temp-table customer
field cs-id as character format "x(5)"
field cs-name as character format "x(20)"
field cs-status as logical format "Yes/No"
field cs-ind1 as character format "x(10)"
field cs-ind2 as character format "x(10)"
field cs-ind3 as character format "x(10)"
field cs-cmnt as character format "x(40)".

define variable iCnt as integer no-undo .

repeat iCnt = 1 to 10:
create customer.
assign
cs-id = "Cust" + string(iCnt)
cs-name = "Cust Name" + string(iCnt)
cs-status = yes
cs-ind1 = "Indicator1." + string(iCnt)
cs-ind2 = "Indicator2." + string(iCnt)
cs-ind3 = "Indicator3." + string(iCnt)
cs-cmnt = if (iCnt modulo 2) = 0  then "This comment has a value for cust " + cs-id else "".
end.

define frame a
cs-id cs-name cs-name cs-status cs-ind1 cs-ind2 cs-ind3 cs-cmnt
with down width 72.

for each customer :
display cs-id  cs-name cs-status cs-ind1 cs-ind2 cs-ind3 with frame a .
if trim(cs-cmnt) <> "" then display cs-cmnt with frame a.
end.


OUTPUT:
┌──────────────────────────────────────────────────────────────────────┐
│cs-id cs-name cs-status cs-ind1 cs-ind2 cs-ind3 │
│cs-cmnt │
│──────────────────────────────────────────────────────────────────────│
│Cust1 Cust Name1 Yes Indicator1 Indicator2 Indicator3 │
│ │ /* I DON'T WANT THIS LINE IF CS-CMNT IS BLANK */
│Cust2 Cust Name2 Yes Indicator1 Indicator2 Indicator3 │
│This comment has a value for cust Cust2 │
│Cust3 Cust Name3 Yes Indicator1 Indicator2 Indicator3 │
│ │
│Cust4 Cust Name4 Yes Indicator1 Indicator2 Indicator3 │
│This comment has a value for cust Cust4 │
│Cust5 Cust Name5 Yes Indicator1 Indicator2 Indicator3 │
│ │
│Cust6 Cust Name6 Yes Indicator1 Indicator2 Indicator3 │
│This comment has a value for cust Cust6 │
│Cust7 Cust Name7 Yes Indicator1 Indicator2 Indicator3 │
│ │
│Cust8 Cust Name8 Yes Indicator1 Indicator2 Indicator3 │
│This comment has a value for cust Cust8 │
│Cust9 Cust Name9 Yes Indicator1 Indicator2 Indicator3 │
│ │
│Cust1 Cust Name10 Yes Indicator1 Indicator2 Indicator3 │
│This comment has a value for cust Cust10 │
└──────────────────────────────────────────────────────────────────────┘

define frame a
cs-id cs-name cs-name cs-status cs-ind1 cs-ind2 cs-ind3 /*NO NEED THIS cs-cmnt */
with down width 72.

for each customer :
display cs-id cs-name cs-status cs-ind1 cs-ind2 cs-ind3 with frame a .
if trim(cs-cmnt) <> "" then DO:
DOWN WITH FRAME a. /* down */
display cs-cmnt @ cs-id with frame a. /* add the @ cs-id */
END.
end.
 

Rajendran_

New Member
define frame a
cs-id cs-name cs-name cs-status cs-ind1 cs-ind2 cs-ind3 /*NO NEED THIS cs-cmnt */
with down width 72.

for each customer :
display cs-id cs-name cs-status cs-ind1 cs-ind2 cs-ind3 with frame a .
if trim(cs-cmnt) <> "" then DO:
DOWN WITH FRAME a. /* down */
display cs-cmnt @ cs-id with frame a. /* add the @ cs-id */
END.
end.
Hello Marco,

This works for me but the format of cs-cmnt is 40 and cs-id is 5. I'm able to only see the first 5 character for cs-cmnt. Is there any work around for this?

I tried adding a format option with display but this effects the actual cs-id on the first display.

Thanks you!
 

LarryD

Active Member
you could try something like this:

Code:
define frame a
    cs-id cs-name cs-name cs-status cs-ind1 cs-ind2 cs-ind3 /*NO NEED THIS cs-cmnt */
    with down width 72.
define frame b
    cs-cmnt with no-labels width 72.

for each customer NO-LOCK :
    display cs-id cs-name cs-status cs-ind1 cs-ind2 cs-ind3 with frame a .
    if trim(cs-cmnt) <> "" then DO:
        DOWN WITH FRAME a. /* down */
        display cs-cmnt with frame b. 
        down with frame b.
    end.
end.
 
Top