Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Finding the next available time slot
Message
From
01/11/2002 19:06:37
Henry Ravichander
RC Management Systems Inc.
Saskatchewan, Canada
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Finding the next available time slot
Miscellaneous
Thread ID:
00718072
Message ID:
00718072
Views:
55
Hi all:

I am working on a form which is expected to do the following:

1. Select a name from the combobox (this works)
2. User clicks the "Find Slot" commandbutton which has the following code:
SELECT app_date, app_time, blocked, lcl_number FROM appointments ;
	INTO CURSOR appointmentlist NOFILTER ;
	WHERE app_date=DATE();
	ORDER BY appointments.app_date,lcl_number


SELECT app_time,Appointime,slot_refer FROM timeslots;
	INTO CURSOR AvailableTimeSlotsForThisDoctor NOFILTER;
	WHERE timeslots.app_time <> appointmentlist.app_time .and.;
		appointmentlist.app_date = mToday .and.; && mToday = date()
		appointmentlist.lcl_number = mDoc_number

GO top

mNextDate = DATE()
mNextSlot = AvailableTimeSlotsForThisDoctor.app_time
mCurrentSlot = AvailableTimeSlotsForThisDoctor.app_time
thisform.Refresh()
3. User clicks the command button "Find Next Slot", which fires the following code:
DO WHILE mSelectThisSlot =.f.

	IF mCurrentslot = 2400 && This is midnight, so change the date
		mNextDate = mNextDate + 1
		SELECT app_date, app_time, blocked, lcl_number FROM appointments ;
			INTO CURSOR appointmentlist NOFILTER ;
			WHERE app_date = mNextDate;
			ORDER BY appointments.app_date,lcl_number
			
		IF _tally >0
			SELECT app_time,Appointime,slot_refer FROM timeslots;
				INTO CURSOR AvailableTimeSlotsForThisDoctor NOFILTER;
				WHERE timeslots.app_time <> appointmentlist.app_time .and.;
					appointmentlist.app_date = mNextDate .and.;
					appointmentlist.lcl_number = mDoc_number
			GO top
			mNextSlot = AvailableTimeSlotsForThisDoctor.app_time
			mCurrentSlot = AvailableTimeSlotsForThisDoctor.app_time
			
			IF !EOF()
				skip
			ENDIF
		ENDIF
	ELSE
		SELECT AvailableTimeSlotsForThisDoctor
		mNextSlot = AvailableTimeSlotsForThisDoctor.app_time
		mCurrentSlot = AvailableTimeSlotsForThisDoctor.app_time
		IF !EOF()
		        skip
		ELSE
			mNextDate = mNextDate + 1
			LOOP
		ENDIF
	
	ENDIF
ENDDO
THISFORM.Refresh()
This is where i am not achieving the desired outcome. What I want happenning each time the user clicks "Find Next Slot" that all available timeslots are reflected in the two text boxes on the form, one show the date that is being processed and the other the timeslot. Clicking on the "Select this" command button sets mSeletThisSlot = .t. at which time the Do While loop should exit.


Where am I going wrong? Thank you for your advise.
- Ravi

True greatness consists in being great in little things.
- Charles Simmons
Next
Reply
Map
View

Click here to load this message in the networking platform