home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a054 / 1.img / GETPRGS.EXE / GETS12.PRG < prev    next >
Encoding:
Text File  |  1992-03-08  |  2.1 KB  |  85 lines

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