Desculpem pela demora, mas só agora eu pude refazer toda a função.
O problema persiste: a keysec() não está funcionando. Ao teclar Enter sobre cada item do dbedit(), ele deveria ficar 20 segundos abertos e voltar ao dbedit(). Mas não está voltando.
Estranhamente, se teclo Del, para executar a função ftecdel(), aí sim ele dá o Esc chamado pela keysec().
Segue todo programa. Se precisarem, posso mandar também o executável e as bases de dados.
Agradeço qualquer ajuda.
Código: Selecionar todos
REQUEST HB_LANG_PT
REQUEST HB_CODEPAGE_PT850
function main()
HB_SETCODEPAGE('PT850')
HB_LANGSELECT('PT')
setmode( 34, 88 )
us="I"
ativ="ativi"
consrsp()
return
function consrsp
usebase("consulta")
copy fields prioridade,arquivo,assunto,tarefa,soluc,exibe,data,hora,vinculo to temp1 for exibe="N" .and. (data<date() .or. (data=date() .and. val(substr(hora,1,2))<val(substr(time(),1,2))) .or. (data=date() .and. val(substr(hora,1,2))=val(substr(time(),1,2)) .and. val(substr(hora,4,2))<val(substr(time(),4,2))))
if usebase("temp1")=.t.
dele for soluc="S" .or. "I"$arquivo .or. prioridade=0
pack
index on prioridade to indcsrs descend
copy to consedit
endif
usebase("consedit")
erase temp1.dbf
keyb "y"
cls
@ maxrow(),5 say "Tecle [ENTER] para mostrar a tarefa completa ou [ESC] para sair"
private v1[4]
v1[1]="Substr(str(Prioridade),1,1)"
v1[2]="arquivo"
v1[3]="Assunto"
v1[4]="substr(tarefa,1,23)"
private v3[4]
v3[1]="Prior."
v3[2]="Nr.tarefa"
v3[3]="Assunto"
v3[4]="Tarefa"
dbedit(,,maxrow()-2,,v1,"responde",,v3)
use
erase consedit.dbf
return
function responde
KEYSEC(27,20,,.t.)
nTecla:=LastKey()
save scre to tlresp
rc=recno()
if nTecla=27 .or. !(alias()=="CONSEDIT") .or. reccount()=0
return(0)
elseif nTecla=7 .and. us="I" //DEL
ftecdel()
return(2)
elseif nTecla=13
ftecenter()
endif
if reccount()<1
return(0)
endif
return(1)
function ftecenter
arq=arquivo
pr=prioridade
as=assunto
ex=exibe
rc=recno()
sol=soluc
prfaz=pr
if usebase(ativ)=.f.
return
endif
append blank
rlbs()
replace data with date()
replace hora with time()
replace acao with "Enter"+alltrim(str(rc))
replace nrtarefa with substr(arq,1,at(".",arq)-1)
replace assunto with as
replace prioridade with pr
go top
arqtemp="\"+arq
if usebase(arq)=.t.
te=tempoestim
rctecp=1
do while .t.
locate for !empty(data) .and. recno()>rctecp .and. at("Inacio",tarefa)=0
if found()
rctecp=recno()
else
exit
endif
enddo
if rctecp>1
go rctecp
else
locate for tempousado=0
skip -1
rctecp=recno()
endif
tu=tempousado
tc=tempocompu
dt=data
hremmin=(val(substr(hora,1,2))*60)+val(substr(hora,4,2))
if tu=0 .and. us="I"
if usebase("ativ"+substr(arq,1,1))=.t.
locate for nrtarefa=substr(arq,1,at(".",arq)-1) .and. data=dt .and. (val(substr(hora,1,2))*60)+val(substr(hora,4,2))>hremmin-3 .and. (val(substr(hora,1,2))*60)+val(substr(hora,4,2))<hremmin+3 .and. acao="Responde"
if found()
tu=tempousado
if tu>=1000
tu=999.9
endif
usebase(arq)
go rctecp
rlbs()
replace tempousado with tu
endif
endif
usebase(arq)
endif
go bottom
skip -15
set color to w/r
clear
@ 0,0 to maxrow(),maxcol() double
@ maxrow()-2,1 say "R-responder; B-atualiza índice só desta tarefa; setas-sobe e desce"
@ maxrow()-1,1 say "1 a 9-adiam a tarefa por 1 a 9 horas; M-adia meia hora; F-adia 5 minutos"
set cursor on
private v1[7]
private v3[7]
v1[1]="Data"
v1[2]="substr(hora,1,5)"
v1[3]="Tarefa"
v3[1]="Data"
v3[2]="Hora"
v1[4]="Tempoestim"
v1[5]="Tempousado"
v1[6]="Tempocompu"
v1[7]="Vinculo"
v3[4]="Tpe"
v3[5]="Tpu"
v3[6]="Tpc"
prvez="S"
sele 3
if usebase(ativ)=.t.
append blank
rlbs()
repl data with date()
repl hora with time()
repl acao with "ENT-III"
endif
use
sele (substr(arq,1,at(".",arq)-1))
dbedit(1,1,maxrow()-6,maxcol()-1,v1,"responde2",,v3)
if usebase("consedit")=.f.
return .f.
endif
go rc
set color to w/b,n/w
cls
return(2)
else
clear
@ 5,5 say "Arquivo não foi aberto; tente novamente em seguida"
tone(261.7,3)
inkey(5)
usebase("consedit")
go rc
return(0)
endif
return
function usebase(nomebase)
bssembarra=nomebase
if at(".DBF",upper(nomebase))>0
nomebase=substr(nomebase,1,at(".DBF",upper(nomebase))-1)
endif
vezusb=0
do while .t.
if file(nomebase+".dbf")
bssembarra=nomebase
do while .t.
if "\"$bssembarra .and. at("\\",bssembarra)=0
bssembarra=substr(bssembarra,at("\",bssembarra)+1)
else
exit
endif
enddo
vezusb=0
if select(bssembarra) = 0
use &nomebase.
else
DbSelectArea(bssembarra)
endif
if neterr()
vezusb++
if ("TAR2P"$upper(hb_progname()) .and. vezusb>240) .or. (at("TAR2P",upper(hb_progname()))=0 .and. vezusb>120)
return .f.
endif
@ maxrow(),1 clear to maxrow(),79
@ maxrow(),1 say "Base "+upper(nomebase)+" ocupada; aguarde liberação ("+alltrim(str(vezusb))+")"
if us="I"
@ maxrow(),45 say "Área: "+alltrim(str(select()))+"; aliás1: "+alias(1)+"; aliás2: "+alias(2)+"; aliás3: "+alias(3)+"; aliás4: "+alias(4)+"; select(nomebase): "+alltrim(str(select(nomebase)))
endif
inkey(5)
desiste:=inkey(8)
if desiste= 27 //K_ESC
conf="N"
@ maxrow()-2,1 clear to maxrow(),79
@ maxrow()-1,5 say "Confirma abandono da tentativa da utilização?"get conf pict "@!"
read
@ maxrow()-2,1 clear to maxrow(),79
if conf="S"
return .f.
endif
endif
else
exit
endif
@ maxrow(),5 clear to maxrow(),79
else
if us="I"
@ 1,1 clear to 23,79
@ 11,5 say "Base "+nomebase+" inexistente"
@ 12,5 say "Bssembarra: "+bssembarra
@ 13,5 say "Pasta corrente: "+curdir()
@ 14,5 say "Função chamadora: "+procname(1)
@ 15,5 say "Linha: "+alltrim(str(procline(1)))
tone(261.7,33)
inkey(15.5)
endif
return .f.
endif
enddo
return .t.
function ftecdel
conf="N"
@ maxrow(),0 clear to maxrow(),maxcol()
@ maxrow(),5 say "Confirma cadastro da tarefa como solucionada?"get conf pict "@!"
read
if conf="S"
arq=arquivo
dele
pack
ftecpdir="N"
if usebase(arq)=.t.
append blank
rlbs()
replace tarefa with "Tarefa solucionada"
replace data with date()
replace hora with time()
endif
if usebase("com"+substr(arq,1,1))=.t.
append blank
rlbs()
repl comandos with (arq)
endif
if usebase("consulta")=.t.
locate for arquivo=arq
if found()
rlbs()
repl soluc with "S"
@ maxrow(),0 clear to maxrow(),maxcol()
@ maxrow(),5 say "Cadastro efetuado com prioridade de envio 0"
inkey(10)
inkey(5)
else
tone(261.7,3)
tone(261.7,3)
@ 23,5 say "Erro: arquivo não encontrado na base CONSULTA"
wait ""
endif
endif
endif
usebase("consedit")
return
function rlbs
nrrl=0
do while .t.
if rlock()=.t.
exit
else
nrrl++
@ maxrow(),1 say "Aguarde tentativa de reservar o registro para uso privado ("+alltrim(str(nrrl))+")"
inkey(3)
@ maxrow(),0 clear to maxrow(),maxcol()
endif
enddo
return
function responde2
nTecla2:=lastkey()
save scre to tlresp2
if nTecla2=27 .or. reccount()=0
rest scre from tlresp2
return(0)
elseif nTecla2=7 .and. us="I" //DEL
if usebase("consedit","S")=.t.
go rc
ftecdel()
endif
return(0)
endif
return(2)