Can anyone help with this script please? It's out of the Xbasic for Everyone book.
Marked in Red where it fails.
Message = "Too many parameters"
Marked in Red where it fails.
Message = "Too many parameters"
Code:
'Date Created: 25-Apr-2011 04:55:39 PM
'Last Updated: 25-Apr-2011 05:24:47 PM
'Created By : Ted
'Updated By : Ted
option strict
dim dstr as c
dim timestr as c
dim lstr as c
dim tstr as c
dim tbl as p
dim patient as p
dim valid as l
patient=table.current()
' overbook attempt
function overbook as l(dstr as c,timestr as c,sched as p)
if sched.records_get()=0 then
overbook=.f.
exit function
end if
if sched.fetch_find(cdate(ctod(dstr))+str(toseconds(timestr),5))>0 then
overbook=.t.
exit function
else
sched.fetch_prev()
if .not. sched.fetch_eof() then
if ctod(dstr)=sched.date then
if toseconds(timestr)<toseconds(sched.time) + (60*sched.length) then
overbook=.t.
exit function
end if
end if
end if
sched.fetch_next()
if .not. sched.fetch_eof() then
if ctod(dstr)=sched.date then
if toseconds(timestr)+(60*val(lstr))>toseconds(sched.time) then
overbook=.t.
exit function
end if
end if
end if
end if
end function
' User interaction **********************************
dstr=ui_get_date("Appointment Date","Enter Appointment Date:",dtoc(date()))
if dstr=""then
end
end if
if ctod(dstr)<date() then
ui_msg_box("Illegal date","Cannot make appointments in the past",UI_STOP_SYMBOL)
end
end if
if exist(ctod(dstr),"holiday.dbf","date")then
ui_msg_box("Illegal date","Office Holiday",UI_STOP_SYMBOL)
end
end if
timestr=ui_get_text("Appointment Time","Enter Appointment Time")
if timestr="" then
end
end if
if toseconds(timestr)<toseconds("9:00 am").or.toseconds(timestr)>toseconds("5:00 pm")then
ui_msg_box("Only appointments between 9 and 5",UI_STOP_SYMBOL)
end
end if
if mod(toseconds(timestr),1800)<>0 then
ui_msg_box("Wrong Time slot","Appointments on the hour and half hour only",UI_STOP_SYMBOL)
end
end if
lstr=ui_get_number("Appointment Length","Minutes of appointment","30")
if val(lstr)<0 then
end
end if
if val(lstr)>60 then
ui_msg_box("1 Hour","One hour maximum appointment length",UI_STOP_SYMBOL)
end
end if
if val(lstr)>30.and. toseconds(timestr)=toseconds("5:00 pm") then
ui_msg_box("Quitting Time","No 1 hour appointments at 5.00 pm.",UI_STOP_SYMBOL)
end
end if
tbl=table.open("schedule.dbf",file_rw_shared)
tbl.index_primary_put("Day_Time")
'*********************************************************************************
'Check for over booking
ui_msg_box("data",dstr)
ui_msg_box("data",timestr)
ui_msg_box("data",lstr)
ui_msg_box("data",tbl)
if overbook(dstr,timestr,lstr,tbl)=.t. then ui_msg_box("Overbooked","Try another time slot",UI_STOP_SYMBOL)
tbl.close()
end
end if
'*********************************************************************************
' No overbook - finish appointment
tstr=ui_get_text("Comment","Enter Comments")
on error goto invalid_appt
valid=.t.
tbl.enter_begin()
tbl.date=ctod(dstr)
tbl.time=timestr
tbl.length=val(lstr)
tbl.comment=left(tstr,40)
tbl.patient_id=patient_id
close:
tbl.enter_end(valid)
tbl.close()
end
invalid_appt:
on error goto 0
valid=.f.
ui_msg_box("Invalid day, time or length","Please verify and try again")
resume close
Comment