Microsoft KB Archive/93905

= Using INTDOSQQ for Password Entry in FORTRAN 5.1 =

PSS ID Number: 93905

Article Last Modified on 5/5/2001

-

The information in this article applies to:


 * Microsoft FORTRAN Compiler for MS-DOS 5.1

-



This article was previously published under Q93905



SUMMARY
You can create a program that allows for password entry using Microsoft FORTRAN version 5.1 for MS-DOS. The Microsoft FORTRAN &quot;Reference&quot; manual for version 5.1 explains using the INTDOSQQ and INTDOSXQQ subroutines to invoke MS-DOS system calls using Interrupt 21h. Interrupt 21h Functions 7 and 8 retrieve input from the keyboard without echoing the input to the display. Interrupt 21h Function 7 ignores the CTRL+C and CTRL+BREAK key combinations while Interrupt 21h Function 8 processes these key combinations by terminating the program. For more information about the various functions provided by Interrupt 21h, see the &quot;MS-DOS Encyclopedia&quot; or another reference on programming in the MS-DOS environment.



MORE INFORMATION
The following sample code use MS-DOS Interrupt 21h Function 7 to allow the user to enter a password without echoing the keystrokes to the display. The application uses Interrupt 21h Function 2 to display an asterisk on the screen for each keystroke entered.

Sample Code
C Compiler options required: None

include 'flib.fi' program password character*80 pass logical get_pass/.true./ integer*2 i, j, getch

write(*,'(1x,a,\)') 'ENTER PASSWORD > ' i=1 do while (get_pass) j = getch           ! Get a character of the password if (j .le. 32) then if (j .eq. 8 .and. i .gt. 1) then  ! BACKSPACE key pressed i = i-1 call putchar( char(j) )   ! Move cursor back 1 character call putchar( ' ' )       ! Write a blank over the asterisk call putchar ( char(j) )  ! Move cursor back to blanks pass(i:i+1) = ' ' endif if (j .eq. 13) get_pass = .false. ! ENTER key pressed - exit else call putchar( '*' )          ! Echo asterisk to display pass(i:i) = char(j)          ! Add input character to string i = i + 1 if (i .gt. 80) get_pass = .false. ! Don't write past string end endif enddo write(*,*) write(*,*) 'password entered > ',pass end

C The GETCH function retrieves a character from the C Standard Input without echoing the character to the screen.

integer*2 function getch include 'flib.fd' record /regs$info/ in, out in.bregs.ah = #07           ! Function 7 - STDIN Input (no echo) call intdosqq(in, out)      ! Interrupt 21h getch = out.bregs.al        ! Input data returned in AL     return end

C The PUTCHAR subroutine writes a single character to the screen.

subroutine putchar( ch ) include 'flib.fd' record /regs$info/ in, out character*1 ch     in.bregs.ah = #02            ! Function 2 - Display Output in.bregs.dl = ch            ! character to display goes in DL     call intdosqq(in, out)       ! Interrupt 21h return end

Additional query words: kbinf 5.10 nofps

Keywords: KB93905

Technology: kbAudDeveloper kbFORTRAN510DOS kbFortranSearch kbZNotKeyword3

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© 2004 Microsoft Corporation. All rights reserved.