- Code: Select all Expand view
function CLASSELIB(nOreClasse, nGiorno, nOra)
local nClasse:= or->classe
local nRecord:= or->(RecNo())
local n:= 1
or->(dbSetOrder(3))
for n:= 0 to nOreClasse - 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.
the function should look in the archive from the beginning if the class corresponds to the class passed. If the date entered in field GG_Ora equals the day-time passed, the function should return a false value otherwise a true value
The index of the archive schedule is set on the third, and that is INDEX ON (upper(CLASSE)+upper(GG_ORA)) TAG ORARIO3
The parameter passed nOreClasse is a number corresponding to the difference in how many hours a class must be committed unless the value of the field ore_as
I use this function in a loop "For Next" which is inside a loop "DoWhile" wich is inside to another cicle "forNext"
for nGiro:= 1 to 10
SELECT OR
OR->(dbSetOrder(2))
OR->(dbGoTop())
while (!OR->(EOF()))
nlezione := OR->(RECNO())
if (Empty(OR->gg_ora) .AND. OR->classe != "1DISP" )
SELECT DO
DO->(dbGoto(OR->prof))
SELECT MA
MA->(dbGoto(OR->materia))
SELECT AU
AU->(dbSeek(OR->aula))
SELECT CL
CL->(dbSeek(OR->classe))
nOreClasse := CL->MAX_ORE-CL->ORE_ASS
SELECT GR
GR->(dbGoto(OR->gruppo))
For nGiorno = 1 to 6 // days of Week at school
for nOre = 1 to 6 // hours
nGG_Ora:= str(nGiorno,1)+str(nOra,1)
IF GiornoLib(nGiorno, @nOre, nOra)
exit
exit
Endif
IF CLASSELIB(nOreClasse, nGiorno, nOre)
cl->ore_ass+=1
or->gg_ora:= nGG_Ora
Endif
next
next
When on the database there is one record he function can run good
but when there are many records as in this case
![Image](http://www.eoeo.it/wp-content/uploads/2015/02/test4.jpg)
and the function not run good
Ho I can resolve ?
I have to explain that a teacher can not 'exist in a class and also in another class at the same time of day past:
teacher 1
monday 1
time 1
classroom 1A
for example if teacher_1 the day Monday at the first hour is in 1A can not' be inserted in 2B at the same time Monday
How can I fix?