how to 'update text(field)' in GUI

Hi

Windows xp and Progress 9.1Ev2

We are in the process of upgrading an old system written in CHUI that uses the TEXT option on an array (ie have defined in the database a field called Ctext with an extent 3). In CHUI the coding UPDATE TEXT(Ctext) would allow word wrapping onto the next extent - ie all 3 lines are treated as one entity.

What I would like to know is there a way to do this under GUI without resorting to an editor-box


Mike
 

ovf

Member
Hi,

I am running progress 10.1a but do not recall the problem from version 9.1d. I just tested the following code:

DEFINE VARIABLE t AS CHARACTER NO-UNDO EXTENT 3 FORMAT "x(30)".
FORM
t[1] COLON 20 LABEL "Text"
t[2] COLON 20 NO-LABEL
t[3] COLON 20 NO-LABEL
WITH SIDE-LABELS WIDTH 80.
UPDATE
TEXT(t)
WITH THREE-D.

And it worked as expected.

Regards Ole
 
Hi Ole and thanks for your reply.

However I should have said that the field is from a database and that it is being 'put onto' a smart viewer.

So the database item is lseries with extent 3 but in adding the fields to the Smart Data Viewer it 'splits' them into separate fields lseries1 lseries2 lseries3 .

Regards
Mike
 

sphipp

Member
You probably don't need a Smart Viewer, the text option above should work.

Or you could use view-as editor as below.

def var a as char extent 20.
def var this_loop as int no-undo.
def var update_text as char view-as editor size 60 by 10.

a[1] = "Hello".
a[3] = "World".

do this_loop = 1 to extent (a):
update_text = update_text +
(if update_text = "" then "" else chr(10)) + a[this_loop].
end.

update update_text with frame f1 no-labels 1 down three-d.

do this_loop = 1 to num-entries (update_text,chr(10)):
if this_loop <= extent (a) then
a[this_loop] = entry (this_loop,update_text,chr(10)).
end.

display a form "x(40)" with side-labels 1 down.
 
Thanks for your reply.
Two things -
1) it is needed on a SDV as there are other fields from the Database that will need updating and they are on the SDV.

2) I have tried the approach with using view-as Editor but the problem with that is - with word wrap being set on the editor box, CHR(10) only occurs if the user presses a RETURN - the editor box does all the formatting of the text. So to move it to line[1], line[2] etc seems to be impossible, not unless there is a way to get the screen image line by line into the array.

Regards
 

RKR

Member
Thanks for your reply.
Two things -
1) it is needed on a SDV as there are other fields from the Database that will need updating and they are on the SDV.

2) I have tried the approach with using view-as Editor but the problem with that is - with word wrap being set on the editor box, CHR(10) only occurs if the user presses a RETURN - the editor box does all the formatting of the text. So to move it to line[1], line[2] etc seems to be impossible, not unless there is a way to get the screen image line by line into the array.

Regards

When you put an editor widget on the screen and you allow wordwrap then the next procedure can help you put all the seperate lines into your extent variable. You can set the max-chars attribute so that the user will not enter to large texts ;-)

Here is the procedure, I hope it will help you to solve the problem. I have put an editor and a button on a window. When I press the button it will invoke this procedure.

PROCEDURE readEditorTextIntoTekstArray:

DEFINE VARIABLE iCnt AS INTEGER NO-UNDO.
DEFINE VARIABLE cTekst AS CHARACTER FORMAT "x(48)" EXTENT 3 NO-UNDO.
DEFINE VARIABLE iStart AS INTEGER NO-UNDO.
DEFINE VARIABLE iEnd AS INTEGER NO-UNDO.

/* editor-1:max-chars = 144 ( 3 lines, 48 characters ) */
DO WITH FRAME {&FRAME-NAME}:
/* Loop through all the lines in the editor widget */
DO iCnt = 1 TO editor-1:NUM-LINES:
/* When it is the first line the startposition is always 1 */
IF iCnt = 1 THEN ASSIGN iStart = 1.
/* If it is not the startposition then the new startposition is the previous end position + 1 */
ELSE ASSIGN iStart = editor-1:CURSOR-OFFSET + 1.

/* If there are more lines then place the cursor on the next line to find the last position of the previous line */
ASSIGN editor-1:CURSOR-LINE = IF editor-1:NUM-LINES > iCnt THEN iCnt + 1 ELSE iCnt
editor-1:CURSOR-CHAR = 1
/* The end position of the line is the cursor offset - 1, or if it is the last line, 144 */
iEnd = IF editor-1:NUM-LINES > iCnt THEN editor-1:CURSOR-OFFSET - 1 ELSE 144.
/* Now we can select the line */
editor-1:SET-SELECTION(iStart,iEnd).
/* And assign the selection to the variable with extent iCnt */
cTekst[iCnt] = ENTRY(1,editor-1:SELECTION-TEXT,"~n").
END.
/* Clear the selection so the user will not see anything of it */
editor-1:CLEAR-SELECTION().
END.
/* Show the array in a message box */
MESSAGE cTekst[1] SKIP cTekst[2] SKIP cTekst[3]
VIEW-AS ALERT-BOX INFO BUTTONS OK.

END PROCEDURE.
 
Top