Problem with running my script

Questions, problems, and other issues for Ascendis Caller ID that aren't covered by the other forums.
Post Reply
jtsoft
Posts: 10
Joined: Sun Nov 21, 2004 2:10 pm

Problem with running my script

Post by jtsoft »

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;
Bill Root
Site Admin
Posts: 1025
Joined: Mon Jan 19, 2004 1:29 pm
Location: Perrysburg, OH
Contact:

Re: Problem with running my script

Post by Bill Root »

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:

Code: Select all

// on Monday through Friday 
if &#40;DayOfWeek&#40;Date&#41; >= 2&#41; and &#40;DayOfWeek&#40;Date&#41; <= 6&#41; then
begin
  if &#40;Time > StrToTime&#40;'8 am'&#41;&#41; and &#40;Time < StrToTime&#40;'4 pm'&#41;&#41; then 
  begin 
    SendMail&#40; 
      // 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&#41;; 
    Speak&#40;'I am Sending Email'&#41;; 
  end 
  else if &#40;Time > StrToTime&#40;'6 pm'&#41;&#41; or &#40;Time < StrToTime&#40;'7 am'&#41;&#41; then 
  begin 
    Speak&#40;'Hanging up after 6 PM'&#41;; 
    HangUp; 
  end
  else
  begin
    Speak&#40;'Doing nothing'&#41;;
  end
end
else 
begin 
  // on Saturday and Sunday 
  HangUp; 
  Speak&#40;'Its Saturday or Sunday and I am Hanging up'&#41;; 
end;
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
jtsoft
Posts: 10
Joined: Sun Nov 21, 2004 2:10 pm

Post by jtsoft »

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
Post Reply