progress
progress

Reputation: 13

Progress 4GL output longchar to screen by splitting it up into chunks

I am using progress and have a field in a database as type longchar.

I cannot output the contents as input/output functions are not allowed with longchar types.

Is there a way to split the longchar up into chunks that I can then store as char type so I can output the entire content of longchar onto the screen?

Thanks

Upvotes: 1

Views: 4956

Answers (2)

Jensd
Jensd

Reputation: 8011

You can actually output LONGCHARS. I might not be practical (depending on the contents of the variable) but it can be done.

In basic ABL you can display a longchar with "view-as editor large" - then you need to set the number of lines and the width in characters.

DEFINE VARIABLE c AS LONGCHAR NO-UNDO.

c = FILL("a", 20000).

DISPLAY c VIEW-AS EDITOR LARGE INNER-LINES 60 INNER-CHARS 100 WITH FRAME f1 WIDTH 120.

In Webspeed you can output a longchar to the webstream easily using the {&OUT-LONG} preprocessor.

{&OUT-LONG} variableName.

Upvotes: 2

Austin
Austin

Reputation: 1255

There are more than one way to do it. One such way is as follows. It splits a LONCHAR variable into chunks and shows them in chunks. But you should remember that a CHARACTER variable cannot have more than 32000 chars (slightly less than 32000 chars in reality) and so you cannot store entire LONGCHAR into a single CHARACTER variable and display it.

DEF VAR l_var AS LONGCHAR. 
DEF VAR chunk_size AS INT64 INIT 30000. 
DEF VAR tot_size AS INT INIT 0. 

DEF VAR char_piece AS CHAR.

COPY-LOB FROM FILE "myfile.txt" TO l_var.

DO WHILE tot_size < LENGTH(l_var):
    char_piece = SUBSTR(l_var,1,chunk_size,"character").
    MESSAGE char_piece.
    tot_size = tot_size + chunk_size.
END.

As far as I know, you cannot have a LONGCHAR field in database.

Upvotes: 2

Related Questions