Microsoft KB Archive/63423

Calling VioGetCurPos to Get Location of Protected Mode Cursor

PSS ID Number: Q63423 Article last modified on 06-29-1990

3.00 3.00a OS/2

Summary: Microsoft COBOL versions 3.00 and 3.00a can call the OS/2 API function VioGetCurPos to get the current cursor position. These versions of COBOL can directly call API functions by prefixing their names with a double underscore (__) and linking with the PCOBOL.LIB and DOSCALLS.LIB libraries. This information applies to Microsoft COBOL Compiler versions 3.00 and 3.00(a) for MS-DOS and MS OS/2.

More Information: VioGetCurPos requires the following parameters:

For API functions, a WORD has a picture clause of “9(4) COMP-5” and must be passed using the BY VALUE clause unless the parameter is preceded by PTR, which specifies BY REFERENCE. The parameters must also be mentioned in reverse order in the CALL statement because API functions use a calling convention that is the reverse of COBOL’s. For more information about calling OS/2 API functions from COBOL 3.00 and 3.00a, see the file OS2API.DOC included with version 3.00a. For more information about VioGetCurPos, see Page 600 of “Advanced OS/2 Programming” by Ray Duncan (Microsoft Press, 1989). The following program (LOCATION.CBL) reports the location of the cursor after a message is displayed on the screen. As with any DISPLAY, the cursor will be located one character to right of the message. To compile and link the program, enter the following: cobol location; link location adis adisinit adiskey,,,pcobol doscalls;

Code Example
$SET ANS85 DATA DIVISION. WORKING-STORAGE SECTION. *  Row coordinate. 01 Y       PIC 9(4) COMP-5. *  Column coordinate. 01 X       PIC 9(4) COMP-5. *  Default video handle. 01 Handle  PIC 9(4) COMP-5 VALUE 0. PROCEDURE DIVISION. *   Clear the screen. CALL X&quot;E4&quot;. DISPLAY &quot;This message starts at row 12 column 10 and it is 11 -           &quot;9 characters long, so it will leave the cursor at row -           &quot;13 column 49.&quot; AT 1210. *   Call VioGetCurPos. CALL &quot;__VioGetCurPos&quot; USING BY VALUE Handle, BY REFERENCE X, BY REFERENCE Y. *    Add 1 to coordinates so they will be reported in range of  *    (1-25),(1-80), the coordinate range for DISPLAYs, instead *   (0-24),(0-79).       COMPUTE Y = Y + 1. COMPUTE X = X + 1. *   Display coordinates. DISPLAY &quot;Row   = &quot; AT 1501. DISPLAY Y.      DISPLAY &quot;Column = &quot; AT 1601. DISPLAY X.      STOP RUN. Copyright Microsoft Corporation 1990.