Now I have another problem with Dbseek
I have Orario.dbf and some index ( i use cdx) with 992 records
USE ORARIO ALIAS OR
INDEX ON OR->PROF TAG ORARIO1 TO ORARIO
INDEX ON (str(PROF,3)+upper(CLASSE)+upper(GG_ORA)+ORESEQ) TAG ORARIO2 TO ORARIO
INDEX ON (upper(OR->CLASSE)+upper(OR->GG_ORA)) TAG ORARIO3 TO ORARIO
tha function I need I used to control if a classrom is free or not
the search is on the same file
the function search the classroom sample "1A" + the day and Hour sample "11"
for a sample :
id found "1A11" then return .T. ( classroom is occupated)
I think it can be only one record with the same "1A11" it is possible have two or many records with the same code
# include "Fivewin.ch"
Function test()
Local ngiorno
local nOra
Local nGiornoOra
USE ORARIO ALIAS OR
INDEX ON OR->PROF TAG ORARIO1 TO ORARIO
INDEX ON (str(PROF,3)+upper(CLASSE)+upper(GG_ORA)+ORESEQ) TAG ORARIO2 TO ORARIO
INDEX ON (upper(OR->CLASSE)+upper(OR->GG_ORA)) TAG ORARIO3 TO ORARIO
or->(dbSetOrder(1))
OR->(dbGoTop())
Do While .not. or->(eof())
for ngiorno= 1 to 6
for nOra:=1 to 6
nGiornoOra := str(ngiorno,1)+str(nOra,1)
If CLASSELIB(1, ngiorno, nOra)
or->gg_ora:= nGiornoOra
or->blocco:= "*"
exit
exit
Endif
next
next
OR->(dbskip())
Enddo
return nil
function CLASSELIB(num, ngiorno, nOra)
nclasse:= or->classe
nRecord:= or->(RecNo())
Local3:= 1
or->(dbSetOrder(3))
OR->(dbGoTop())
for n= 0 to num - 1
if (or->(dbSeek(nclasse + Str(ngiorno, 1) + iif(nOra + n ;
== 10, "0", Str(nOra + n, 1)))))
or->(dbSetOrder(1))
or->(dbGoto(nRecord))
return .F.
endif
next
or->(dbSetOrder(1))
or->(dbGoto(nRecord))
return .T.
it is possible it found many records because there are teachers have some hour on a classroom with different materia
How I can resolve ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com