Home > Archive > Clipper > January 2006 > Timing out a READ
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Robert J. Stuart 2005-12-18, 3:55 am |
| I there a way to time out a READ. I am building these user terminals where
the user swipes his mag stripe card thru a reader. Then the rest is all
touch screen control, no keyboard attached. I want a way to time out a
read, say after 30 seconds or so once the user has swiped his mag stripe
card and identifies him but does not do any user entry. This is so a
terminal will not hang for a long period of time. Any suggestions?
Bob S.
| |
| Turan Fettahoglu 2005-12-18, 7:55 am |
| For this you must alter the GETSYS.PRG and link it explicitly into your .RMK
/ .LNK.
I cannot look into Getsys right now, but you might find it yourself. In
Getsys.prg there is a function call where there is an INKEY(0) in a
parameter. This is the line where any keystroke in Clipper is processed.
Alter this INKEY(0) to, say INKEY(30) for 30 seconds. Then you must find out
what to do if a READ is ended with a Timeout.
If you do not find out I can look into an old programme and tell you.
Turan
| |
| Robert J. Stuart 2005-12-18, 7:55 am |
| Turan,
Thank you. That did the trick. I found the INKEY command and #defined
it a variable. Then added a if nkey=0, nkey=27 which made the function call
think that the escape key had been hit and then exiting the read with no
action taken. Thank you again
Bob S.
"Turan Fettahoglu" <turan.fe@invalid> wrote in message
news:do3ccq$v9k$02$1@news.t-online.com...
> For this you must alter the GETSYS.PRG and link it explicitly into your
..RMK
> / .LNK.
>
> I cannot look into Getsys right now, but you might find it yourself. In
> Getsys.prg there is a function call where there is an INKEY(0) in a
> parameter. This is the line where any keystroke in Clipper is processed.
> Alter this INKEY(0) to, say INKEY(30) for 30 seconds. Then you must find
out
> what to do if a READ is ended with a Timeout.
>
> If you do not find out I can look into an old programme and tell you.
>
> Turan
>
| |
| Dave P 2006-01-10, 3:55 am |
| ideal timer in ur app you should create your own inkey()
and use it everywhere....i handle mouse since i only use 52e...did not need
too go too 53 since i had already wrote
everything 53 came out with
you can add a 2nd parameter too run background stuff...or popup menus within
other routines, timers, screen savers...
take a look at the code below....
myinkey()
The timerevent functions are too have multiple functions run at different
times in the application for instance
screen saver
com port monitor
lots of stuff.....
set a function too moniter key strokes while in the getsys
you dont have too get as complex as i have just make ur own inkey and
implement the needs of your application
Small samble below...more complex sample lower
funcion myinkey(nWaitState) // i think 5.3 has a mouse parameter...
LOCAL nStartTime
local nkey
if (nStartTime:=Seconds())==86399 //midnite
nStartTime:=0
endif
DO WHILE (Seconds()-nStartTime)<=nWaitState
nkey:=inkey() // get any key or 5.3 mouse clicks
if ! (nkey=0)
exit
endif
Enddo
Return nkey
/*
Clipper Version 52e
*/
#INCLUDE "DVS.CH"
#INCLUDE "inkey.CH"
#INCLUDE "SETCURS.CH"
static aTimerBlocks:={}
static nTimerLen:=0
#xtranslate xnTime2Wait => 1
#xtranslate xbTimerBlock => 2
#xtranslate xcTimerName => 3
#xtranslate xnTmp => 4 // disable/all enable all
#xTranslate xnTimer => 5
// ****************************************
*********
FUNCTION TimerEvAdd(nTime,bTimerBlock,cTimerName,
lDelAll)
// ****************************************
**********
if ! (lDelAll==NIL) .AND. lDelAll
//placed here for backward compatibility of old dos code
//that used a single Backround block routine
aTimerBlocks:={}
endif
aadd(aTimerBlocks,{nTime,bTimerBlock,cTi
merName,nTime,0})
nTimerLen:=len(atimerBlocks)
return(nil)
// *********************************
Function TimerEvSet(cName,nTime)
// **********************************
local nPos,nTmp:=0,X
if cName=="DISABLE"
for x:=1 to nTimerLen
aTimerBlocks[x][xnTmp]:=aTimerBlocks[x][
xnTime2Wait]
aTimerBlocks[x][xnTime2Wait]:=0
next
ELSEIF cName=="ENABLE"
for x:=1 to nTimerLen
aTimerBlocks[x][xnTime2Wait]:=aTimerBloc
ks[x][xnTmp]
aTimerBlocks[x][xnTmp]:=0
next
ELSE
if (nPos:=Ascan(aTimerBlocks,{|ele|ele[xcTi
merName]==cName }))>0
nTmp:=aTimerblocks[npos][xnTime2Wait]
IF ! (ntime==NIL)
aTimerBlocks[npos][xnTime2Wait]:=nTime
ENDIF
else
Dialogbox("OKONLY","Timer Not found;")
endif
ENDIF
Return(nTmp)
// **************************
function TimerEvDel(cname,cAll)
//***************************
local nPos
IF (nPos:=aScan(aTimerBlocks,{|ele|ele[xcTi
merName]==cname }))>0
atimerblocks:=a2del(atimerblocks,npos,{3
,{||qqout("hello
orld") },0,0})
asize(aTimerBlocks,ntimerlen-1)
nTimerLen:=len(aTimerBlocks)
endif
return(nil)
// ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Function MINKEY(nHOLD,bBlock)
// ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
local x,bHotkeyBlock,nKey:=0,bTimerBlock,nTime
r,nStarttime,acsr,ahelp,;
nSecs
// if midnight messes up math for timouts
if (nTimer:=int(Seconds()))==86399 //midnite
nTimer:=0
endif
for x:=1 to ntimerlen
aTimerBlocks[x][xnTimer]:=ntimer
next
nStartTime:=nTimer
// code block for do while loop
//nil=drop in fall out
//0=for ever loop like inkey(0)
//else time sent in so do while elaps time
bTimerBlock:=IF(nHold==NIL,{||.F.},;
IF(nHold==0,{||.t.},;
{||(SECONDS()-nStarttime)<=nHold}))
_MouseOn()
DO WHILE Eval(bTimerBlock)
// mouse stuff
IF MinButton(0)
// nKey:=K_MOUSE_1
stuffkey(CHR(K_MOUSE_1))
ELSEIF MinButton(1)
// nKey:=K_MOUSE_2
stuffkey(chr(K_MOUSE_2))
ELSEIF MinButton(2)
// nkey:=K_MOUSE_3
Stuffkey(chr(K_MOUSE_3))
ENDIF
NKEY:=INKEY() // normal inkey without paramaters
if nkey==0 .and. nTimerlen>0 ///any timer event set
nSecs:=Seconds()
for x:=1 to ntimerlen
//check each timer event and see if it time too
fire a event
if aTimerBlocks[x][xnTime2Wait]>0 .and. ;
((nSecs-atimerblocks[x][xnTimer])>=aTimerBlocks[x][xnTime2Wait])
//fire the code block if present
if Valtype(aTimerBlocks[x][xbTimerBlock])==
"B"
Eval(aTimerBlocks[x][xbTimerBlock])
endif
//reset Timer
atimerBlocks[x][xnTimer]:=Seconds()
endif
next
Endif
//check for standard hotkeys
bHotKeyBlock := SETKEY( nKey )
IF VALTYPE( bHotKeyBlock ) == "B"
if valtype(bBlock)=="B"
EVAL(bBlock)
endif
//save current cursor position
aCsr:={row(),col(),setcursor()}
EVAL( bHotKeyBlock, PROCNAME(1),
PROCLINE(1),readvar())
//reset cursor position
setpos(aCsr[1],aCsr[2])
setcursor(aCsr[3])
// Return key Already Evaluated
// Mailly for Getsystem and other areas that need to
complete
// other work like, Redraw New Screeen
RETURN(0)
ENDIF
// end clock ****************************************
**
IF nkey!=0
RETURN(nkey)
ENDIF
ENDDO
//this if here if no parameter sent into this function fals through and
checks for mouse clicks
IF MinButton(0)
// nKey:=K_MOUSE_1
stuffkey(CHR(K_MOUSE_1))
ELSEIF MinButton(1)
// nKey:=K_MOUSE_2
Stuffkey(chr(K_MOUSE_2))
ELSEIF MinButton(2)
// nkey:=K_MOUSE_3
Stuffkey(chr(K_MOUSE_3))
ENDIF
NKEY:=INKEY()
RETURN(NKEY)
// *********************************
function ShowClock(nRow,nCol,cClr,cAmpm)
// *********************************
local aSaveStuff,cTime
aSaveStuff:={row(),col(),SET(_SET_CURSOR
,SC_NONE)}
if cClr==NIL
cClr:=Setcolor()
endif
if empty(campm) .OR. cAmpm=="MILITARY"
cTime:=SUBSTR(Time(),1,5)
else
cAmpm:=AMPM(time())
ctime:=substr(cAmpm,1,5)+substr(cAmpm,9)
endif
DEVPOS(nRow,nCol);devout(cTime,cClr)
setpos(aSaveStuff[1],aSaveStuff[2])
set(_SET_CURSOR,aSaveStuff[3])
return(nil)
FUNCTION CLRLASTKEY()
STUFFKEY(CHR(255))
MINKEY()
RETURN(NIL)
"Robert J. Stuart" <rjstuart@earthlink.net> wrote in message
news:gL6pf.7457$nm.7370@newsread2.news.atl.earthlink.net...
> I there a way to time out a READ. I am building these user terminals
where
> the user swipes his mag stripe card thru a reader. Then the rest is all
> touch screen control, no keyboard attached. I want a way to time out a
> read, say after 30 seconds or so once the user has swiped his mag stripe
> card and identifies him but does not do any user entry. This is so a
> terminal will not hang for a long period of time. Any suggestions?
>
>
> Bob S.
>
>
| |
| Dave P 2006-01-10, 3:55 am |
|
use readmodal() you can make new paramaters
or
change the read command too support the new parameters
I perfer the Readmodal() approach
dave
"Robert J. Stuart" <rjstuart@earthlink.net> wrote in message
news:gL6pf.7457$nm.7370@newsread2.news.atl.earthlink.net...
> I there a way to time out a READ. I am building these user terminals
where
> the user swipes his mag stripe card thru a reader. Then the rest is all
> touch screen control, no keyboard attached. I want a way to time out a
> read, say after 30 seconds or so once the user has swiped his mag stripe
> card and identifies him but does not do any user entry. This is so a
> terminal will not hang for a long period of time. Any suggestions?
>
>
> Bob S.
>
>
| |
| Robert J. Stuart 2006-01-10, 3:55 am |
| Dave, Thanks. That looks just like what I am wanting to do. If you don't
mind, I am going to borrow some of your code and expand on it for my
purpose. Thanks for getting me started in the right direction.
Bob S.
"Dave P" <dvs_bis@sbcglobal.net> wrote in message
news:k3Cpf.117$oW.71@newssvr11.news.prodigy.com...
> ideal timer in ur app you should create your own inkey()
> and use it everywhere....i handle mouse since i only use 52e...did not
need
> too go too 53 since i had already wrote
> everything 53 came out with
> you can add a 2nd parameter too run background stuff...or popup menus
within
> other routines, timers, screen savers...
> take a look at the code below....
> myinkey()
> The timerevent functions are too have multiple functions run at different
> times in the application for instance
> screen saver
> com port monitor
> lots of stuff.....
> set a function too moniter key strokes while in the getsys
> you dont have too get as complex as i have just make ur own inkey and
> implement the needs of your application
> Small samble below...more complex sample lower
>
> funcion myinkey(nWaitState) // i think 5.3 has a mouse parameter...
> LOCAL nStartTime
> local nkey
> if (nStartTime:=Seconds())==86399 //midnite
> nStartTime:=0
> endif
>
> DO WHILE (Seconds()-nStartTime)<=nWaitState
> nkey:=inkey() // get any key or 5.3 mouse clicks
> if ! (nkey=0)
> exit
> endif
> Enddo
> Return nkey
>
>
> /*
> Clipper Version 52e
> */
> #INCLUDE "DVS.CH"
>
> #INCLUDE "inkey.CH"
> #INCLUDE "SETCURS.CH"
> static aTimerBlocks:={}
> static nTimerLen:=0
>
> #xtranslate xnTime2Wait => 1
> #xtranslate xbTimerBlock => 2
> #xtranslate xcTimerName => 3
> #xtranslate xnTmp => 4 // disable/all enable all
> #xTranslate xnTimer => 5
>
>
> // ****************************************
*********
> FUNCTION TimerEvAdd(nTime,bTimerBlock,cTimerName,
lDelAll)
> // ****************************************
**********
> if ! (lDelAll==NIL) .AND. lDelAll
> //placed here for backward compatibility of old dos code
> //that used a single Backround block routine
> aTimerBlocks:={}
> endif
> aadd(aTimerBlocks,{nTime,bTimerBlock,cTi
merName,nTime,0})
> nTimerLen:=len(atimerBlocks)
> return(nil)
> // *********************************
> Function TimerEvSet(cName,nTime)
> // **********************************
> local nPos,nTmp:=0,X
> if cName=="DISABLE"
> for x:=1 to nTimerLen
> aTimerBlocks[x][xnTmp]:=aTimerBlocks[x][
xnTime2Wait]
> aTimerBlocks[x][xnTime2Wait]:=0
> next
> ELSEIF cName=="ENABLE"
> for x:=1 to nTimerLen
> aTimerBlocks[x][xnTime2Wait]:=aTimerBloc
ks[x][xnTmp]
> aTimerBlocks[x][xnTmp]:=0
> next
>
> ELSE
> if (nPos:=Ascan(aTimerBlocks,{|ele|ele[xcTi
merName]==cName }))>0
> nTmp:=aTimerblocks[npos][xnTime2Wait]
> IF ! (ntime==NIL)
> aTimerBlocks[npos][xnTime2Wait]:=nTime
> ENDIF
>
> else
> Dialogbox("OKONLY","Timer Not found;")
> endif
> ENDIF
> Return(nTmp)
> // **************************
> function TimerEvDel(cname,cAll)
> //***************************
> local nPos
> IF (nPos:=aScan(aTimerBlocks,{|ele|ele[xcTi
merName]==cname }))>0
> atimerblocks:=a2del(atimerblocks,npos,{3
,{||qqout("hello
> orld") },0,0})
> asize(aTimerBlocks,ntimerlen-1)
> nTimerLen:=len(aTimerBlocks)
> endif
> return(nil)
> // ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
> Function MINKEY(nHOLD,bBlock)
> // ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
> local x,bHotkeyBlock,nKey:=0,bTimerBlock,nTime
r,nStarttime,acsr,ahelp,;
> nSecs
>
> // if midnight messes up math for timouts
>
> if (nTimer:=int(Seconds()))==86399 //midnite
> nTimer:=0
> endif
> for x:=1 to ntimerlen
> aTimerBlocks[x][xnTimer]:=ntimer
> next
> nStartTime:=nTimer
> // code block for do while loop
> //nil=drop in fall out
> //0=for ever loop like inkey(0)
> //else time sent in so do while elaps time
> bTimerBlock:=IF(nHold==NIL,{||.F.},;
> IF(nHold==0,{||.t.},;
> {||(SECONDS()-nStarttime)<=nHold}))
> _MouseOn()
>
> DO WHILE Eval(bTimerBlock)
> // mouse stuff
> IF MinButton(0)
> // nKey:=K_MOUSE_1
> stuffkey(CHR(K_MOUSE_1))
> ELSEIF MinButton(1)
> // nKey:=K_MOUSE_2
> stuffkey(chr(K_MOUSE_2))
> ELSEIF MinButton(2)
> // nkey:=K_MOUSE_3
> Stuffkey(chr(K_MOUSE_3))
> ENDIF
> NKEY:=INKEY() // normal inkey without paramaters
>
> if nkey==0 .and. nTimerlen>0 ///any timer event set
> nSecs:=Seconds()
> for x:=1 to ntimerlen
>
> //check each timer event and see if it time too
> fire a event
> if aTimerBlocks[x][xnTime2Wait]>0 .and. ;
>
> ((nSecs-atimerblocks[x][xnTimer])>=aTimerBlocks[x][xnTime2Wait])
> //fire the code block if present
> if
Valtype(aTimerBlocks[x][xbTimerBlock])==
"B"
> Eval(aTimerBlocks[x][xbTimerBlock])
>
> endif
> //reset Timer
> atimerBlocks[x][xnTimer]:=Seconds()
> endif
> next
> Endif
>
> //check for standard hotkeys
> bHotKeyBlock := SETKEY( nKey )
> IF VALTYPE( bHotKeyBlock ) == "B"
> if valtype(bBlock)=="B"
> EVAL(bBlock)
> endif
> //save current cursor position
> aCsr:={row(),col(),setcursor()}
> EVAL( bHotKeyBlock, PROCNAME(1),
> PROCLINE(1),readvar())
> //reset cursor position
> setpos(aCsr[1],aCsr[2])
> setcursor(aCsr[3])
> // Return key Already Evaluated
> // Mailly for Getsystem and other areas that need
to
> complete
> // other work like, Redraw New Screeen
> RETURN(0)
> ENDIF
> // end clock ****************************************
**
> IF nkey!=0
> RETURN(nkey)
> ENDIF
>
> ENDDO
> //this if here if no parameter sent into this function fals through and
> checks for mouse clicks
> IF MinButton(0)
> // nKey:=K_MOUSE_1
> stuffkey(CHR(K_MOUSE_1))
> ELSEIF MinButton(1)
> // nKey:=K_MOUSE_2
> Stuffkey(chr(K_MOUSE_2))
> ELSEIF MinButton(2)
> // nkey:=K_MOUSE_3
> Stuffkey(chr(K_MOUSE_3))
> ENDIF
> NKEY:=INKEY()
> RETURN(NKEY)
> // *********************************
> function ShowClock(nRow,nCol,cClr,cAmpm)
> // *********************************
> local aSaveStuff,cTime
> aSaveStuff:={row(),col(),SET(_SET_CURSOR
,SC_NONE)}
> if cClr==NIL
> cClr:=Setcolor()
> endif
> if empty(campm) .OR. cAmpm=="MILITARY"
> cTime:=SUBSTR(Time(),1,5)
> else
> cAmpm:=AMPM(time())
> ctime:=substr(cAmpm,1,5)+substr(cAmpm,9)
> endif
> DEVPOS(nRow,nCol);devout(cTime,cClr)
> setpos(aSaveStuff[1],aSaveStuff[2])
> set(_SET_CURSOR,aSaveStuff[3])
> return(nil)
>
> FUNCTION CLRLASTKEY()
> STUFFKEY(CHR(255))
> MINKEY()
> RETURN(NIL)
>
> "Robert J. Stuart" <rjstuart@earthlink.net> wrote in message
> news:gL6pf.7457$nm.7370@newsread2.news.atl.earthlink.net...
> where
>
>
| |
| Ian Boys 2006-01-10, 3:55 am |
| If you have Tools III then you can use:
KEYSEC([<nKeyValue>,<nTime>, [<nCounter>],[<lMode>]]) --> lActivated
to trigger a pseuto keypress, Escape or Enter of a function key after a wait
period.
Ian Boys
DTE
| |
| Dave P 2006-01-10, 3:55 am |
| you can use anything of mine....not a problem....
if you want i can send my whole library..and you will have tons of code
examples too look at ..
from Replacing atpromt, achoice, etc.....
my getsys has a lot of ideas you can see how too do things within the
getsys....and my header file dvs.ch has lots of new commands and enhnced
existing commands...
and expanded Get object .....will give you lots more ideas you can impliment
dave
dvs_bis@sbcglobal.net
"Robert J. Stuart" <rjstuart@earthlink.net> wrote in message
news:7%Cpf.7034$3Z.554@newsread1.news.atl.earthlink.net...
> Dave, Thanks. That looks just like what I am wanting to do. If you
don't
> mind, I am going to borrow some of your code and expand on it for my
> purpose. Thanks for getting me started in the right direction.
>
> Bob S.
>
> "Dave P" <dvs_bis@sbcglobal.net> wrote in message
> news:k3Cpf.117$oW.71@newssvr11.news.prodigy.com...
> need
> within
different[color=darkred]
too[color=darkred]
> Valtype(aTimerBlocks[x][xbTimerBlock])==
"B"
> to
all[color=darkred]
a[color=darkred]
stripe[color=darkred]
>
>
| |
| Dave P 2006-01-10, 3:55 am |
| I Don't like too use 3rd party libraries...for the most part...thats why i
wrote most of my own code
but thanks.
dave
"Ian Boys" <NotGiven@BTInternet.com> wrote in message
news:do6ugq$i20$1@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com...
> If you have Tools III then you can use:
> KEYSEC([<nKeyValue>,<nTime>, [<nCounter>],[<lMode>]]) --> lActivated
> to trigger a pseuto keypress, Escape or Enter of a function key after a
wait
> period.
>
> Ian Boys
> DTE
>
>
| |
| Robert J. Stuart 2006-01-10, 3:55 am |
| Dave, I am always looking for new ideas. Right now I am so consumed with
this project, I have to get it done before I get to play. But if you don't
mind, I would love to see your code and header file. If you want to zip it
all up and email to me at rjstuart@earthlin.net , that would be great. I
also have a FTP site that I maintain in the office for over 10Mbs files that
need to be transferred that the email system will not handle. If you need
to use it, just email me and I will set up an account on it for you.
Bob S.
"Dave P" <dvs_bis@sbcglobal.net> wrote in message
news:0KEpf.31213$BZ5.5054@newssvr13.news.prodigy.com...
> you can use anything of mine....not a problem....
> if you want i can send my whole library..and you will have tons of code
> examples too look at ..
> from Replacing atpromt, achoice, etc.....
> my getsys has a lot of ideas you can see how too do things within the
> getsys....and my header file dvs.ch has lots of new commands and enhnced
> existing commands...
> and expanded Get object .....will give you lots more ideas you can
impliment
>
> dave
> dvs_bis@sbcglobal.net
> "Robert J. Stuart" <rjstuart@earthlink.net> wrote in message
> news:7%Cpf.7034$3Z.554@newsread1.news.atl.earthlink.net...
> don't
> different
x,bHotkeyBlock,nKey:=0,bTimerBlock,nTime
r,nStarttime,acsr,ahelp,;[color=darkred]
set[color=darkred]
> too
need[color=darkred]
and[color=darkred]
terminals[color=darkred]
> all
out[color=darkred]
> a
> stripe
a[color=darkred]
>
>
|
|
|
|
|