Category : Dbase (Clipper, FoxBase, etc) Languages Source Code
Archive   : NN0506.ZIP
Filename : TEST.PRG

 
Output of file : TEST.PRG contained in archive : NN0506.ZIP
/***
* Test.prg
*
* Tests TIMER GET
* Compile Clipper /n /a /w
*/
#include "Readers.ch"

PROCEDURE Test()
LOCAL cVar := SPACE(5)

SET TIMER TO 30 // or: nOldTimer := SetTimer( 30 )

CLS
@ 10,10 SAY "You have 30 seconds for each keystroke." ;
TIMER GET cVar
READ

? cVar

QUIT


/***
* Timer.prg
* Timed Gets via a user supplied reader.
*
* Compile: Clipper timer /n /a /w
*/

#include "Readers.ch"

// File Wide Static
STATIC nTimeAllowed := 0 // a value of 0 means
// forever ( ala INKEY() )


/***
* TimedReader()
* Standard GetReader() with very slight modification
*/
PROCEDURE TimedReader( oGet )
LOCAL nKey := 0 // NOTE: add a local to hold keystroke

// Read the Get if the WHEN condition is satisfied
IF GetPreValidate( oGet )

// Activate the Get for reading
oGet:SetFocus()

DO WHILE oGet:exitState == GE_NOEXIT

// Check for initial READMODAL (no editable positions)
IF oGet:typeOut
oGet:exitState := GE_ENTER
ENDIF

// Apply keystrokes until exit
DO WHILE oGet:exitState == GE_NOEXIT
// If KeyPoller() times out it will return a 0 and sets
// oGet:exitState to GE_ESCAPE so exit this loop
// NOTE: Add polling routine
IF ( nKey := KeyPoller( oGet ) ) != 0
// We have a valid key
// NOTE: INKEY(0) changed nKey
GetApplyKey( oGet, nKey )
ENDIF
ENDDO

// Disallow exit if the VALID condition is not satisfied
IF !GetPostValidate( oGet )
oGet:exitState := GE_NOEXIT
ENDIF
ENDDO

// Deactivate the Get
oGet:KillFocus()
ENDIF
RETURN

/***
* KeyPoller()
*/
FUNCTION KeyPoller( oGet )
LOCAL nKey := 0
LOCAL nStart := SECONDS()

DO WHILE nKey == 0 .AND. ((SECONDS() - nStart) <= nTimeAllowed )
nKey := INKEY()
// The following line is for demonstration purposes only.
// It should be removed or replaced with your own clock
// (or something READMODAL)
@ 0,50 SAY "READMODAL time: " + ;
LTRIM( STR( SECONDS() - nStart ) )
ENDDO

IF nKey == 0
// Uh-oh, no key stroke
// Causes read to terminate
oGet:exitState := GE_ESCAPE
ENDIF

RETURN (nKey)


/***
* SetGetTimer( nTime )
*/
FUNCTION SetGetTimer( nTime )
LOCAL nOldTime

nOldTime := nTimeAllowed
nTimeAllowed := nTime

RETURN (nOldTime)


  3 Responses to “Category : Dbase (Clipper, FoxBase, etc) Languages Source Code
Archive   : NN0506.ZIP
Filename : TEST.PRG

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/