home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a054 / 1.img / GETPRGS.EXE / GETS10.PRG < prev    next >
Encoding:
Text File  |  1992-02-18  |  1.5 KB  |  71 lines

  1. /***
  2. * Gets10.prg
  3. *
  4. * Get reader with timeout
  5. */
  6.  
  7. #include "Getexit.ch"
  8.  
  9. #command READ TIMEOUT AT <n>                                   ;
  10.         =>                                                     ;
  11.         Aeval(GetList,                                         ;
  12.               {|o| o:reader :=                                 ;
  13.                   {|oGet| TimedReader(oGet, <n>) } })         ;;
  14.         READ
  15.  
  16. MEMVAR GetList
  17.  
  18. FUNCTION Gets10
  19.  
  20. LOCAL cVar1 := Space(10), ;
  21.       cVar2 := Space(15), ;
  22.       cVar3 := Space(12)
  23.  
  24.   CLEAR SCREEN
  25.   @ 10, 10 SAY "Enter cVar1" GET cVar1
  26.   @ 11, 10 SAY "Enter cVar2" GET cVar2
  27.   @ 12, 10 SAY "Enter cVar3" GET cVar3
  28.  
  29.   READ TIMEOUT AT 4
  30.  
  31. RETURN NIL
  32.  
  33.  
  34. proc TimedReader( get, nTimeOut )
  35.  
  36. LOCAL nKey
  37.  
  38.   // read the GET if the WHEN condition is satisfied
  39.   IF ( GetPreValidate(get) )
  40.     // activate the GET for reading
  41.     get:SetFocus()
  42.  
  43.     DO WHILE ( get:exitState == GE_NOEXIT )
  44.       // check for initial typeout (no editable positions)
  45.       IF ( get:typeOut )
  46.         get:exitState := GE_ENTER
  47.       ENDIF
  48.  
  49.       // apply keystrokes until exit
  50.       DO WHILE ( get:exitState == GE_NOEXIT )
  51.         IF (nKey := InKey(nTimeOut)) != 0
  52.           GetApplyKey(get, nKey)
  53.         ELSE
  54.           get:exitState := GE_ESCAPE
  55.         ENDIF
  56.       ENDDO
  57.  
  58.       // disallow exit if the VALID condition is not satisfied
  59.       IF ( !GetPostValidate(get) )
  60.         get:exitState := GE_NOEXIT
  61.       ENDIF
  62.     ENDDO
  63.  
  64.     // de-activate the GET
  65.     get:KillFocus()
  66.   ENDIF
  67.  
  68. RETURN
  69.  
  70.  
  71.