Lantica Software Support Center
Lantica Software Home Page


Knowledgebase

Creating a Follow-Up Scheduler


Uses:

  • Program a form to display a follow-up menu on demand (making the need to manually type in a follow-up date unnecessary).
  • Learn how to do "arithmetic" with data values.

This sample program displays a pop-up selection list with the following callback intervals (change to suit):

Today, Tomorrow, Next Weekday, 5 days, 10 days, 15 days, 20 days, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday, User-entered date

Because the @PopupMenu() function displays the list in alphabetical order, the days of the week selections follow a A-Monday, B-Tuesday... format, to keep them together and in proper sequence.

When you make a selection (other than User-entered date), Sesame automatically fills the CallbackDate field with the date that corresponds to it, then moves you to the next element on the form.

The program can be attached to a Command Button's On Element Entry event.

var CallbackTemp as string

CallbackTemp = @PopupMenu("User-entered date;Today;Tomorrow;Next Weekday;5 Days;10 Days;14 Days;20 Days;A-Monday;B-Tuesday;C-Wednesday;D-Thursday;E-Friday;F-Saturday;G-Sunday", "SELECT A CALL BACK DATE");

If @Instr(CallbackTemp, "-") = 3 Then
{
	CallbackTemp = @Del(CallbackTemp, 1, 4);
	If @Dow$(@Date + 1) = CallbackTemp Then CallbackDate = @Date + 1
	Else if @Dow$(@Date + 2) = CallbackTemp Then CallbackDate = @Date + 2
	Else if @Dow$(@Date + 3) = CallbackTemp Then CallbackDate = @Date + 3
	Else if @Dow$(@Date + 4) = CallbackTemp Then CallbackDate = @Date + 4
	Else if @Dow$(@Date + 5) = CallbackTemp Then CallbackDate = @Date + 5
	Else if @Dow$(@Date + 6) = CallbackTemp Then CallbackDate = @Date + 6
	Else if @Dow$(@Date + 7) = CallbackTemp Then CallbackDate = @Date + 7
	CNext
}

If CallbackTemp = "User-entered date" Then
{
	@Msg("Type in the Callback Date and press Enter")
	Clear(CallbackDate)
	Goto CallbackDate
}

If CallbackTemp = "Today" Then
{
	CallbackDate = @Date
	CNext
}

If CallbackTemp = "Tomorrow" Then
{
	CallbackDate = @Date + 1;
	CNext
}

If CallbackTemp = "Next Weekday" Then
{
	If @Dow$(@Date) = "Friday" Then CallbackDate = @Date + 3
	Else If @Dow$(@Date) = "Saturday" Then CallbackDate = @Date + 2
	Else CallbackDate = @Date + 1
	CNext
}

If CallbackTemp = "" Then
{
	ThrowFocus(CallbackDate)
}
Else
{
	CallbackDate = @Date + Tn(@Num(CallbackTemp))
}

By placing the following optional program in the "On Element Change" event for CallbackDate, you'll be alerted if you accidently enter a date that's in the past, or too far in the future:

If CallbackDate > @Date + 30 Then
{
        If @AskUser("Follow-up date is more than 30 days away!", "Do you really want to leave it that way?", "") Then
	{
		CNext
	}
}
Else
{
	ThrowFocus(CallbackDate)
}

If CallbackDate <> "" Then
{
	If CallbackDate < @Date Then
	{
                If @AskUser("Follow-up date is earlier than today!", "Do you really want to leave it that way?", "") Then
	{
		CNext
	}
	Else
	{
		ThrowFocus(CallbackDate)
	}
	}
}

This, and other programming examples, can be found in "Appendix 2: Advanced Programming Examples" in the Sesame Programming Guide