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

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