Hi,
My script doesn't seem to execute on the last else for Saturdays and Sundays.
Basically, is my over all script look ok or need corrections?
Thanks!
JT
//LANGUAGE=DWS
// on Monday through Friday
if (DayOfWeek(Date) >= 2) and (DayOfWeek(Date) <= 6) then
if (Time > StrToTime('8 am')) and (Time < StrToTime('4 pm')) then
begin
SendMail(
// from email address
'jtsoft@tampabay.rr.com',
// recipient email address
'jeff.tomich@geac.com',
// subject
'Call from ' + CallInfo.Name + ' at ' + CallInfo.Number,
// message
'Call received on line ' + CallInfo.Line);
Speak('I am Sending Email');
end
else if (Time > StrToTime('6 pm')) or (Time < StrToTime('7 am')) then
begin
Speak('Hanging up after 6 PM');
HangUp;
end
else
begin
// on Saturday and Sunday
HangUp;
Speak('Its Saturday or Sunday and I am Hanging up');
end;
Problem with running my script
Re: Problem with running my script
Hi JT,
Looks like all you were missing was a begin/end around the Monday-Friday code. When using multiple IF statements, it easy to confuse which IF an ELSE is associated with when you don't use begin/end. I recommend using begin/end whenever you have nested IFs. Using begin/end never hurts, and if you don't use it when you need to, the meaning of the code can change dramatically.
Here's the patched code:
I also added the "Speak('Doing nothing');" statement in the Monday-Friday code to indicate when the time conditions are not met.
Other than the begin/end, the code looks fine. The Speak statements you added are great for debugging!
Finest regards,
Bill Root
Ascendis Software
Looks like all you were missing was a begin/end around the Monday-Friday code. When using multiple IF statements, it easy to confuse which IF an ELSE is associated with when you don't use begin/end. I recommend using begin/end whenever you have nested IFs. Using begin/end never hurts, and if you don't use it when you need to, the meaning of the code can change dramatically.
Here's the patched code:
Code: Select all
// on Monday through Friday
if (DayOfWeek(Date) >= 2) and (DayOfWeek(Date) <= 6) then
begin
if (Time > StrToTime('8 am')) and (Time < StrToTime('4 pm')) then
begin
SendMail(
// from email address
'jtsoft@tampabay.rr.com',
// recipient email address
'jeff.tomich@geac.com',
// subject
'Call from ' + CallInfo.Name + ' at ' + CallInfo.Number,
// message
'Call received on line ' + CallInfo.Line);
Speak('I am Sending Email');
end
else if (Time > StrToTime('6 pm')) or (Time < StrToTime('7 am')) then
begin
Speak('Hanging up after 6 PM');
HangUp;
end
else
begin
Speak('Doing nothing');
end
end
else
begin
// on Saturday and Sunday
HangUp;
Speak('Its Saturday or Sunday and I am Hanging up');
end;
Other than the begin/end, the code looks fine. The Speak statements you added are great for debugging!
Finest regards,
Bill Root
Ascendis Software
Thanks Bill!
I wanted to add my email since, we can't run a script within a script at this time.
I know the code look like the same I sent before, but you can see I added the email that was in another script.
Thank for helping again. I'm learning alot though thru you showing how it should be done.
Again, thanks!
Jt
I wanted to add my email since, we can't run a script within a script at this time.
I know the code look like the same I sent before, but you can see I added the email that was in another script.
Thank for helping again. I'm learning alot though thru you showing how it should be done.
Again, thanks!
Jt