PreviousNextIndex

PUT CURSOR statement


(Character only)

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

In data-handling statements such as UPDATE, SET, PROMPT-FOR, and INSERT, the AVM 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: Does not apply to SpeedScript programming.
Syntax

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

OFF
ROW expression
COLUMN expression
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 the AVM stored the typed information.

r-cursor.p
DEFINE VARIABLE comment AS CHARACTER NO-UNDO FORMAT "x(30)" EXTENT 4. 
DEFINE VARIABLE iRow    AS INTEGER   NO-UNDO. 
DEFINE VARIABLE iCol    AS INTEGER   NO-UNDO. 
DEFINE VARIABLE lmargin AS INTEGER   NO-UNDO INITIAL 5. 
DEFINE VARIABLE rmargin AS INTEGER   NO-UNDO INITIAL 34. 
DEFINE VARIABLE ptop    AS INTEGER   NO-UNDO INITIAL 10. 
DEFINE VARIABLE pbot    AS INTEGER   NO-UNDO INITIAL 13. 
DEFINE VARIABLE r-ofst  AS INTEGER   NO-UNDO INITIAL 9. 
DEFINE VARIABLE c-ofst  AS INTEGER   NO-UNDO 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. 
ASSIGN 
  iRow = ptop 
  iCol = lmargin. 
REPEAT: 
  PUT CURSOR ROW iRow COLUMN iCol. 
  READKEY. 
  IF KEYFUNCTION(LASTKEY) = "GO" THEN LEAVE. 
  IF KEYFUNCTION(LASTKEY) = "END-ERROR" THEN RETURN. 
  IF LASTKEY = KEYCODE("CURSOR-RIGHT") THEN DO: 
    iCol = iCol + 1. 
    IF iCol > rmargin THEN iCol = lmargin. 
    NEXT. 
  END. 
  IF LASTKEY = KEYCODE("CURSOR-LEFT") THEN DO: 
    iCol = iCol - 1. 
    IF iCol < lmargin THEN iCol = rmargin. 
    NEXT. 
  END. 
  IF LASTKEY = KEYCODE("CURSOR-DOWN") THEN DO: 
    iRow = iRow + 1. 
    IF iRow > pbot THEN iRow = ptop. 
    NEXT. 
  END. 
  IF LASTKEY = KEYCODE("CURSOR-UP") THEN DO: 
    iRow = iRow - 1. 
    IF iRow < ptop THEN iRow = pbot. 
    NEXT. 
  END. 
  IF LASTKEY = KEYCODE("RETURN") THEN DO : 
    iRow = iRow + 1. 
    IF iRow > pbot THEN iRow = ptop. 
    iCol = lmargin. 
    NEXT. 
  END. 
  IF LASTKEY = KEYCODE("BACKSPACE") THEN DO: 
    IF iCol = lmargin AND iRow = ptop THEN NEXT. 
    iCol = iCol - 1. 
    IF iCol < lmargin THEN DO: 
      iCol = rmargin. 
      iRow = iRow - 1. 
      IF iRow < ptop THEN iRow = ptop. 
    END. 
    PUT SCREEN ROW iRow COLUMN iCol " ". 
    OVERLAY(comment[iRow - r-ofst], iCol - c-ofst) = " ". 
    NEXT. 
  END. 
  IF LASTKEY >= 32 AND LASTKEY <= 126 THEN DO: 
    PUT SCREEN ROW iRow COLUMN iCol KEYLABEL(LASTKEY). 
    OVERLAY(comment[iRow - r-ofst], iCol - c-ofst) = KEYLABEL(LASTKEY). 
    iCol = iCol + 1. 
    IF iCol > rmargin THEN DO: 
      iCol = lmargin. 
      iRow = iRow + 1. 
      IF iRow > pbot THEN iRow = 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


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex