Microsoft KB Archive/50002

How to Use CALL X“AF” in COBOL 3.00 to Accept a Password

PSS ID Number: Q50002 Article last modified on 01-15-1993

3.00 3.00a MS-DOS

Summary: CALL X“AF” can be used to accept hidden text, such as a password. When using the ACCEPT and Call X“AF” to conceal text, the AT keyword on the ACCEPT must be used, otherwise COBOL will not go through the ADIS modules and the Call X“AF” will not conceal the text. This information applies to Microsoft COBOL Versions 3.00 and 3.00a for MS-DOS.

More Information: The CALL X“AF” is documented in the “Microsoft COBOL Version 3.0: Operating Guide” in Chapter 8, Page 16 (i.e., Page 8-16). The following program demonstrates the use of CALL X“AF” to conceal a password entered from the keyboard. Compiling and Linking: COBOL filename.cob; LINK filename+@adis.lnk;

Code Example: $Set ans85 IDENTIFICATION DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 78 CALL-NO-AF VALUE X“AF”. 01 CALL-FLAG PIC 99 COMP VALUE 1. 01 PARM-BLOCK. 03 CONTROL1 PIC 99 COMP. 03 SYMBOL-1 PIC X VALUE “2”. 03 FACILITY PIC 99 COMP VALUE 84. 03 SYMBOL-2 PIC 99 COMP VALUE 1. 01 PASSWD PIC X(10). 01 PASSWD2 PIC X(10). 01 PAUSE PIC X(1). Screen Section. 01 Blank-screen. 05 Blank screen. PROCEDURE DIVISION. MAIN. DISPLAY SPACE. MOVE 1 TO CONTROL1. ******************************************************** * CALL TO TURN ON PASSWORD MASKING   CONTROL1 = 0 sets to default normal accept.   CONTROL1 = 1 only for next accept.   CONTROL1 = 2 suppresses echoing until reenabled ******************************************************* CALL CALL-NO-AF USING CALL-FLAG, PARM-BLOCK. DISPLAY Blank-screen. DISPLAY “Password:[ ]” AT 1010. ACCEPT PASSWD AT 1020. DISPLAY Blank-screen. CALL call-no-af USING call-flag, parm-block. DISPLAY “Please enter password again” AT 0805. DISPLAY “Password:[ ]” AT 1010. ACCEPT PASSWD2 AT 1020. DISPLAY Blank-screen. IF (passwd = passwd2) DISPLAY “Welcome to the application” AT 1515 ELSE DISPLAY “Wrong password” AT 1515. DISPLAY “Enter a key to continue.” with blink at 2520. ACCEPT pause AT 2546. DISPLAY Blank-screen. STOP RUN.

Copyright Microsoft Corporation 1993.