Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strange Problem using SCAN ENDSCAN

Status
Not open for further replies.

MForrest

Programmer
Jun 9, 2003
85
GB
Hi all, was wondering if you could take a quick look at this section of code for me. I use this code as part of a diary it is called each time an appointment is made to scan the table diary to see if the client is available. I have put a dummy record in my diary table so that even when the diary could be empty there is something to scan. Though I have a record in my table to mark the client as unavailable during a specific time of a specific date only on the first occurance of running this code the appointment is not recognising the client unavailable record and the client appointment is saved, on the second try of saving an appointment on that same day the appointment (as it should be) will not save as the client is unavailable. If I close the system down and run it again the appointment checking program works fine so it just seems to be when i have one dummy record and the first time I check the diary.

* check the clients availabilty if we are wanting to save a client appointment, check if the client is already scheduled for an appointment or if they are unavailable
if Client_id != -1
select 'diary'
go top
* locate for appointment == client_id and where the new appointment date/time falls between an existing
* appointments date/time within diary.dbf. Check that you do not include cancelled or deleted appointments
SCAN FOR diary.client_no == Client_id and BETWEEN(starttime,diary.start_time,diary.end_time) and diary.cancelled == .F. and !deleted()
* make sure the user is not updating an existing appointment
if found() and diary.support_no != App_id
if starttime == diary.end_time
* if the start time follows on from and end time assign .T.
Client_Accepted = .T.
else
* the appointment times are taken for the client assign .F.
Client_Accepted = .F.
endif
endif
ENDSCAN

* locate for appointment == client_id and where the new appointment date/time proceeds and exceeds an existing
* appointment within diary.dbf. Check that you do not include cancelled or deleted appointments
select 'diary'
go top
SCAN FOR diary.client_no == Client_id and starttime < diary.start_time and endtime > diary.start_time and diary.cancelled == .F. and !deleted()
* make sure the user is not updating an existing appointment
if found() and diary.support_no != App_id
* the appointment times are taken for the tutor assign .F.
Client_Accepted = .F.
endif
ENDSCAN
endif
 
When using the debugger to run through the code I can see that the appointment is recognised by the first scan as seeing an appointment trying to be made between the dates of an existing appointment but it is when I get to the
' if found() and diary.support_no != App_id' where the problem occurs even though the client unavailable appointment is found and the diary.support_no == 2 and the app_id == -1.

because the if statement is skipped the appointment is wrongly saved as the client is unavailable all day. The second time i try save an appointment for that day even though I can see in the debugger that when i hit the same if statement and compare the same client unavailable record with the diary.support_no == 2 and the app_id == -1 the if statement is recognised and the variable client_accepted == .f. therefore not saving the appointment as it should do.

If any more info is required to understand this better I will gladly supply as this is just alien behavior to me.
 
No bother seem to have it working now, just made my dummy record have a few extra bits of info.

Cheers Michelle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top