home *** CD-ROM | disk | FTP | other *** search
- /***
- * Gets09.prg
- *
- * Get reader with timeout
- */
-
- #include "Getexit.ch"
-
- #command @ <row>, <col> GET <var> ;
- [<clauses,...>] ;
- TIMEOUT <n> ;
- [<moreClauses,...>] ;
- ;
- => @ <row>, <col> GET <var> ;
- [<clauses>] ;
- SEND reader := {|oGet| TimedReader(oGet, <n>) } ;
- [<moreClauses>]
-
- MEMVAR GetList
-
- FUNCTION Gets09
-
- LOCAL cVar1 := Space(10), ;
- cVar2 := Space(15), ;
- cVar3 := Space(12)
-
- CLEAR SCREEN
- @ 10, 10 SAY "Enter cVar1" GET cVar1 TIMEOUT 3
-
- @ 11, 10 SAY "Enter cVar2" GET cVar2 TIMEOUT 10
-
- @ 12, 10 SAY "Enter cVar3" GET cVar3 TIMEOUT 5
-
- READ
-
- RETURN NIL
-
-
- proc TimedReader( get, nTimeOut )
-
- LOCAL nKey
-
- // read the GET if the WHEN condition is satisfied
- IF ( GetPreValidate(get) )
- // activate the GET for reading
- get:SetFocus()
-
- DO WHILE ( get:exitState == GE_NOEXIT )
- // check for initial typeout (no editable positions)
- IF ( get:typeOut )
- get:exitState := GE_ENTER
- ENDIF
-
- // apply keystrokes until exit
- DO WHILE ( get:exitState == GE_NOEXIT )
- IF (nKey := InKey(nTimeOut)) != 0
- GetApplyKey(get, nKey)
- ELSE
- get:exitState := GE_ESCAPE
- ENDIF
- ENDDO
-
- // disallow exit if the VALID condition is not satisfied
- IF ( !GetPostValidate(get) )
- get:exitState := GE_NOEXIT
- ENDIF
- ENDDO
-
- // de-activate the GET
- get:KillFocus()
- ENDIF
-
- RETURN
-