Progress
Language Reference


PUT CURSOR Statement

Interfaces
OS
SpeedScript
Character
All
No

Makes the cursor visible on the screen at a specified position.

In data handling statements such as UPDATE, SET, PROMPT-FOR, and INSERT, the Progress 4GL handles cursor display so the user knows where the cursor is located in the window. However, if data is entered through the READKEY statement, and that statement is not part of an EDITING phrase, you might want to turn the cursor on so the user can see the location of the cursor while entering data.

NOTE: This statement is only supported in character environments.

SYNTAX

PUT CURSOR
  {     OFF
     |  { [ ROW expression ] [ COLUMN expression ] }
  } 

OFF

Ends display of the cursor.

ROW expression

The row in which you want to display the cursor. In the ROW option, expression is a constant, field name, variable name, or expression whose value is an integer that indicates the row where you want to display the cursor. If you do not use the ROW option, PUT CURSOR does not reposition the cursor. Similarly, if you specify a ROW that is outside the screen area, Progress does not reposition the cursor.

COLUMN expression

The column in which you want to display the cursor. In the COLUMN option, expression is a constant, field name, variable name, or expression whose value is an integer that indicates the column where you want to display the cursor. If you do not use the COLUMN option, PUT CURSOR does not reposition the cursor. Similarly, if you specify a COLUMN that is outside the windows area, Progress does not repositions the cursor.

EXAMPLE

The following procedure uses PUT CURSOR to make the cursor visible in an editor window. When you run the procedure, you see a frame in a window. You can type text into this frame. The procedure reads each key you enter and takes the appropriate action. Then PUT CURSOR places the cursor in the first row and the first column in the editing frame when you first run the procedure. As you type, the cursor continues to be visible. As the procedure passes through the REPEAT loop for each keystroke, it takes action based on each keystroke and moves the cursor as it takes the action.

The procedure stores the information you type in the comments array, one character at a time. When you finish typing, press GO. The procedure displays the array where Progress stored the typed information.

r-cursor.p
DEFINE VARIABLE comment AS CHARACTER FORMAT "x(30)" EXTENT 4.
DEFINE VARIABLE r       AS INTEGER.
DEFINE VARIABLE c       AS INTEGER.
DEFINE VARIABLE lmargin AS INTEGER INITIAL 5.
DEFINE VARIABLE rmargin AS INTEGER INITIAL 34.
DEFINE VARIABLE ptop    AS INTEGER INITIAL 10.
DEFINE VARIABLE pbot    AS INTEGER INITIAL 13.
DEFINE VARIABLE r-ofst  AS INTEGER INITIAL 9.
DEFINE VARIABLE c-ofst  AS INTEGER INITIAL 4.
FORM SKIP(4) WITH WIDTH 32 ROW 9 COL 4 TITLE "Editor".

MESSAGE "Type text into the editor.  Press" KBLABEL("GO") "to end.". 

VIEW.
r = ptop.
c = lmargin. 
REPEAT:
   PUT CURSOR ROW r COLUMN c.
   READKEY.
   IF KEYFUNCTION(LASTKEY) = "GO" THEN LEAVE.
   IF KEYFUNCTION(LASTKEY) = "END-ERROR" THEN RETURN.
   IF LASTKEY = KEYCODE("CURSOR-RIGHT") THEN DO:
      c = c + 1.
      IF c > rmargin
      THEN c = lmargin.
      NEXT.
   END.
   IF LASTKEY = KEYCODE("CURSOR-LEFT") THEN DO:
      c = c - 1.
      IF c < lmargin
      THEN c = rmargin.
      NEXT.
   END.
   IF LASTKEY = KEYCODE("CURSOR-DOWN") THEN DO:
      r = r + 1.
      IF r > pbot
      THEN r = ptop.
      NEXT.
   END.
   IF LASTKEY = KEYCODE("CURSOR-UP") THEN DO:
      r = r - 1.
      IF r < ptop
      THEN r = pbot.
      NEXT.
   END.
   IF LASTKEY = KEYCODE("RETURN") THEN DO :
       r = r + 1.
       IF r > pbot
       THEN r = ptop.
       c = lmargin.
       NEXT.
   END. 
   IF LASTKEY = KEYCODE("BACKSPACE") THEN DO:
      IF c = lmargin AND r = ptop
      THEN NEXT.
      c = c - 1.
      IF c < lmargin THEN DO:
          c = rmargin.
          r = r - 1.
          IF r < ptop
          THEN r = ptop.
      END.
      PUT SCREEN ROW r COLUMN c " ".
      OVERLAY(comment[r - r-ofst], c - c-ofst) = " ".
      NEXT.
   END.
   IF LASTKEY >= 32 AND LASTKEY <= 126 THEN DO:
      PUT SCREEN ROW r COLUMN c KEYLABEL(LASTKEY).
      OVERLAY(comment[r - r-ofst], c - c-ofst) = KEYLABEL(LASTKEY).
      c = c + 1.
      IF c > rmargin THEN DO:
          c = lmargin.
          r = r + 1.
          IF r > pbot
          THEN r = ptop.
      END.
   END.
END.
DISPLAY comment WITH FRAME x NO-LABELS
   TITLE "Comments Array" 1 COLUMN ROW 09 COLUMN 40.
MESSAGE "Information stored in the comments array.". 

NOTES

SEE ALSO

PUT SCREEN Statement


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095