Wrapping text within a form?

Posted by James Palmer on 08-Jul-2016 04:53

Further to my other thread, is it possible to wrap text in a form? My definition is below. The description is truncated to 52 characters, but the data entry allows longer descriptions. The client wants to be able to see the whole thing. Any ideas?

    form 
        entryitem.product              at 2  format 'x(12)'
        wcustomerproduct               at 15 format 'x(12)'
        product.description            at 27 format 'x(52)'
        w-units                        at 79
        w-prime                        at 88 skip

    With Column 1 Row 1 Overlay  width 180 no-box Down no-labels
         no-attr-space STREAM-IO use-text frame f-detail.

All Replies

Posted by Steve Moore on 08-Jul-2016 05:12

One trick I use is have the field set as an editor.

product.description at 27 view-as editor size 52 by 1

This can be inconsistent though, and seems to work best if it is the last field in the form. I seem to recall a problem if not the last field in the form and it does not have a value the later fields do not print.

Posted by Matt Gilarde on 08-Jul-2016 05:15

I believe that the output will be wrapped if you add VIEW-AS EDITOR SIZE <columns> BY <rows> to the field you want to wrap.

form
    entryitem.product              at 2  format 'x(12)'
    wcustomerproduct               at 15 format 'x(12)'
    product.description            at 27 format 'x(52)' VIEW-AS EDITOR SIZE 52 by 2
    w-units                        at 79
    w-prime                        at 88 skip

Posted by Matt Gilarde on 08-Jul-2016 05:17

Steve beat me to it. I think that the bug he's talking about was fixed in 11.0.

Posted by LarryDusch on 08-Jul-2016 05:51

Another option is to check the length of product.description and see if it exceeds 52 characters.  If it does, then do a down , then display the rest of the description.

Something along the lines of e.g.

[code]
display stream blah
    entryitem.product .... with frame f-detail.

if length(product.description) > 52
then do:
    down stream blah with frame f-detail.
    display stream blah substring(product.description,53) @ product.description with frame f-detail.
   down stream blah with frame f-detail.
end.

[/code]

And if you want to be fancy you could r-index from column 52 to find the first blank and parse the description based on that.

(Sorry James, first post and I haven't figured out how to post code yet).

Posted by James Palmer on 08-Jul-2016 05:57

Thanks for that. Unfortunately we're on 10.2B and it seems that when it wraps then any subsequent fields are missing from that line.

Posted by James Palmer on 08-Jul-2016 05:58

Thanks Larry that's not a bad option although I suspect it means subsequent fields will end up on the wrapped line not the original line which isn't ideal. Still better than not displaying at all though!

Posted by LarryDusch on 08-Jul-2016 06:05

Actually it won't do the subsequent fields on the wrapped line.  You display all the fields on the initial display, then the second based on length will only display the rest of the description and nothing else.   I've had to do this with fields that can span multiple lines using that code (descriptions, comments, etc).

Posted by James Palmer on 08-Jul-2016 06:21

Of course! You sir are an absolute legend!

Posted by Thomas Mercer-Hursh on 08-Jul-2016 09:42

One of the basic principles of handling issues like this and the footer problem is simply to cut the frame up into smaller frames.  E.g., make a separate footer frame and view it when you want (allowing you to decide if it follows the text or appears at the bottom of the page.  Or, separate frames for what is above the description, the description, and what follows the description.  This allows you to either use an editor widget and resize it to fit or to manually slice the description into lines and use the frame more than once.  Crude, but it works.

This thread is closed