home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / fortran / mslang / f32int / funkey.for next >
Text File  |  1993-06-25  |  2KB  |  56 lines

  1.       include 'int86qq.fi'
  2.       program getkeys
  3.       character spec_key*2
  4.       logical get_key/.true./
  5.       integer*2 i,j,getch               
  6.       data spec_key/'F '/
  7.                                                  
  8.       write(*,'(1x,a)') 'ENTER FUNCTION AND ARROW KEYS OR ESCAPE '   
  9.       i=1
  10.       do while (get_key)
  11.          j=getch()                       ! Get SPECIAL KEY
  12.          if (j.eq.27) then
  13.             write(*,*) 'ESC key pressed'
  14.          elseif (j.le.13) then
  15.             if (j.eq.13) get_key=.false. ! ENTER key pressed - exit loop
  16.             if (j.eq.0) then   ! *** SPECIAL KEY LOGIC ***
  17.                j=getch()                   
  18.                if (j.ge.59.AND.j.le.68) then  ! test for function key
  19.                   spec_key='F '       
  20.                   if (j.lt.68) then
  21.                      write(spec_key(2:2),'(i1)') j-58
  22.                      write(*,*) spec_key
  23.                   else
  24.                      write(*,*) 'F10'
  25.                   endif
  26.                elseif (j.eq.72) then
  27.                   write(*,*) 'Up arrow'
  28.                elseif (j.eq.77) then
  29.                   write(*,*) 'Right arrow'
  30.                elseif (j.eq.80) then
  31.                   write(*,*) 'Down arrow'
  32.                elseif (j.eq.75) then
  33.                   write(*,*) 'Left arrow'   
  34.                endif
  35.             endif 
  36.          else
  37.             write(*,*) 'ASCII = ',char(j)
  38.          endif
  39.       enddo                            
  40.       end
  41.  
  42. c  The getch function gets a character from Standard Input without echo.
  43. c  When a special key is pressed (like a function key or arrow key) this
  44. c  function returns a 0.  This function should then be called again to 
  45. c  obtain the scan code.  From this returned scan code, you can determine
  46. c  which special key was pressed.
  47.                      
  48.       integer*2 function getch
  49.       include 'int86qq.fd'
  50.       record /regs$info/ in,out
  51.       in.bregs.ah=#08             ! Function 7 - STDIN Input (without echo)
  52.       call int86qq(int2(#21),in,out)     ! INT 21H
  53.       getch=out.bregs.al          ! Input data returned in AL
  54.       return
  55.       end
  56.