Highlighted
Absent Member.
Absent Member.
1214 views

[archive] Display last line in Multiline Entry Field while populating

[Migrated content. Thread originally posted on 31 January 2005]

I am using a multiline entry field like an optput window, as in AcuBench, displaying messages line by line as certain tasks are being performed. I want the user to see the last message added to the multiline entry field while the next task is being performed

How do I tell the control to scroll down to the last line as the message field is added?

some code:

Working Storage Section.
03 wMsg PIC (6000).
03 msg-ptr PIC 9(4).

Screen Section.
....
03 msg-obj entry-field VSCROLL-BAR value wMsg.
....

move "new message to user" to add-msg
perform add-to-msg

move "another message to user" to add-msg
perform add-to-msg
....

add-to-msg.
inspect add-msg replacing trailing spaces by low-values
string add-msg delimited by low-values H"0D" H"0A" delimited by size into wMsg with pointer msg-ptr
modify msg-obj values wMsg
modify msg-obj cursor 6000

Help is much appreciated.
0 Likes
6 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Display last line in Multiline Entry Field while populating

Thanks Davide the reason I want to use entry field is so that the user can select and copy/paste/print messages if needed.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Display last line in Multiline Entry Field while populating

Have you tried sending the data as keystrokes to the entry field with W$KEYBUF?
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Display last line in Multiline Entry Field while populating

Thanks Dan for the tip. No I have not tried it and haven't thought of it either. Shall try it and let your know how I get on...
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Display last line in Multiline Entry Field while populating

Well Dan I have tried to use "w$keybuf" but I can't seem to get it to display my text in the edit control. How does the runtime know where to display the text sent into the keyboard buffer? Have you done this before? Tech Support thinks that "w$keybuf" does not work in GUI controls, i.e. display text.

Any more thoughts?
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Display last line in Multiline Entry Field while populating

Not sure why support thinks w$keybuf doesn't work in an entry-field but it does.
Ok, a simpler way to do this is to send just one keystroke, a Ctrl-End, with W$KEYBUF. This will move the cursor to the end of the text in an entry-field.


CALL "W$KEYBUF" USING 1, "{kE}" .

Do this after your tasks are done and just before accept returns to your entry-field.
If using screen-section and you need to move focus to your entry-field then use:


|Replace ID-NUMBER with entry-fields' ID number.
MOVE ID-NUMBER TO CONTROL-ID.
MOVE 4 TO ACCEPT-CONTROL.


If you need do this in a loop where you have Task, Message, Accept, then you need to terminate the accept to get back into loop for your next interation. So, use "{kE}{^I}" to both send Ctl-End and a Tab to exit the accept.

Here's a sample program:

       IDENTIFICATION DIVISION.
       PROGRAM-ID. WKEYBUF.
       AUTHOR. Dan Maltes.
       DATE-WRITTEN. 2/03/2005.
       REMARKS. This sample moves cursor in entry-field to last line,
                as data is added, by sending keystrokes with W$KEYBUF.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SPECIAL-NAMES.
       WORKING-STORAGE SECTION.
          COPY "CRTVARS.DEF".

       77 MAIN-WINDOW         HANDLE OF WINDOW.
       77 ESCAPE-CODE         PIC 9(03) VALUE 0.
       78 MAX-LINES           VALUE 40.
       77 TEXT-LINES          OCCURS 40 TIMES PIC X(MAX-LINES).
       77 LINE-NO             PIC 9(02) VALUE 0.

       SCREEN SECTION.
       01 TEST-SCREEN.
          05 E-FIELD, ENTRY-FIELD
             VALUE MULTIPLE TEXT-LINES
             LINE 3 COL 5 LINES 9 SIZE 40
             VSCROLL-BAR, NO-AUTOSEL.
          05 PUSH-BUTTON
             COLUMN 5, LINE 15, LINES 2 CELLS, SIZE 20 CELLS
             TITLE "Send Message"
             SELF-ACT
             EXCEPTION-VALUE = 1.


       PROCEDURE DIVISION.
       MAIN SECTION.
           DISPLAY STANDARD GRAPHICAL WINDOW
              LINES 20, SIZE 65
              TITLE-BAR, SYSTEM MENU, AUTO-RESIZE
              TITLE "Send Keys Sample"
              BACKGROUND-LOW
              HANDLE MAIN-WINDOW.

           DISPLAY TEST-SCREEN.
           |Set focus to button.
           MOVE 2 TO CONTROL-ID.
           MOVE 4 TO ACCEPT-CONTROL.
           PERFORM UNTIL ESCAPE-CODE = 27
              ACCEPT TEST-SCREEN
              ACCEPT ESCAPE-CODE FROM ESCAPE KEY
              IF ESCAPE-CODE = 1
                 |Append message text to entry-field.
                 PERFORM 10 TIMES
                    IF LINE-NO NOT > MAX-LINES
                        ADD 1 TO LINE-NO
                        STRING "This is text line #", LINE-NO
                           INTO TEXT-LINES(LINE-NO)
                    END-IF
                 END-PERFORM
                 DISPLAY E-FIELD
                 |Set focus to entry-field(on next accept).
                 MOVE 1 TO CONTROL-ID
                 MOVE 4 TO ACCEPT-CONTROL
                 |Send Ctl-End and Tab keystrokes.
                 |Ctl-End moves cursor to end of entry-field and
                 |Tab will terminate accept and move focus to next
                 |control which is the button.
                 CALL "W$KEYBUF" USING 1, "{kE}{^I}"
              END-IF
           END-PERFORM.

           DESTROY ALL CONTROLS.
           DESTROY MAIN-WINDOW.

           EXIT PROGRAM.
           STOP RUN.

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Display last line in Multiline Entry Field while populating

Thank you Dan for taking the time to code a workable routine. It is very much appreciated.

Shaylesh
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.