Why isn't this script working correctly?

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

Why isn't this script working correctly?

Post by jtsoft »

I'm trying to hangup on phone callers that call between Monday-Friday and if the time is after 5PM but before 8AM. It seems to ignore the times if statement, because its hanging up the phone caller.

Also, if its Sat or Sun, times are ignored so just hangup on them.

Any help is much appreciated.

Jt

if (DayOfWeek(Date)>=2) and (DayOfWeek(Date)<=6) then
if (Time > StrToTime('5 pm')) and (Time < StrToTime('8 am')) then
begin
HangUp;
end
else if (DayOfWeek(Date)=1) or (DayOfWeek(Date)=7) then
begin
HangUp;
end
Bill Root
Site Admin
Posts: 1025
Joined: Mon Jan 19, 2004 1:29 pm
Location: Perrysburg, OH
Contact:

Re: Why isn't this script working correctly?

Post by Bill Root »

Hi JT,

It looks like you were close! I think this will do what you need:

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 after 5 pm or before 8 am
  if &#40;Time > StrToTime&#40;'5 pm'&#41;&#41; or &#40;Time < StrToTime&#40;'8 am'&#41;&#41; then 
  begin 
    HangUp; 
  end;
end
else
begin
  // on Saturday and Sunday
  HangUp; 
end;
The problems were that
1) you were checking for the time being after 5 pm AND less than 8 am. In computer terms this is impossible (a time can't be > 5 pm and < 8 am), so I changed the AND to an OR.
2) The first IF clause (checking the days) needed a begin/end to isolate the time comparison. This also makes the second day-checking if clause unnecessary.

The script above, like yours, is not complete -- at a minimum it needs a "//LANGUAGE=DWS" line at the top.

If you discover that this still doesn't do what you need, let me know and I'll change it.

Finest regards,
Bill Root
Ascendis Software
jtsoft
Posts: 10
Joined: Sun Nov 21, 2004 2:10 pm

Post by jtsoft »

Hi Bill,

Unfortunately it didn't work. I have some calls already listed of out of area calls after 5PM and some before it and tested it, and it didn't work.

Btw, I had the or in there before, but your changes looked better.

I put a speak in it when I tested it. Being before 5PM it fell into the if times.

I'm really confused now.

Thanks,
JT
Bill Root
Site Admin
Posts: 1025
Joined: Mon Jan 19, 2004 1:29 pm
Location: Perrysburg, OH
Contact:

Post by Bill Root »

Hi JT,

It sounds like you're testing using calls already in the calls list. That won't work for the code we wrote, since it checks the current time, not the time when the call came in. The next beta will have a way to get the call time from the script. Until then, you could change your system clock temporarily for testing, or wait until the appropriate time to make a test call.

If this doesn't clear things up, please let me know!

Finest regards,
Bill Root
Ascendis Software
Guest

Post by Guest »

Okay, will do. didn't think about the time is the current time not the time in the call list.

I'll let ya know, thanks again.

JT
Bill Root
Site Admin
Posts: 1025
Joined: Mon Jan 19, 2004 1:29 pm
Location: Perrysburg, OH
Contact:

Post by Bill Root »

Hi JT,

I just posted a new beta version that has CallInfo.Time working correctly for 'Test Action'. The above script could be rewritten as follows:

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 after 5 pm or before 8 am
  if &#40;CallInfo.Time > StrToTime&#40;'5 pm'&#41;&#41; or &#40;CallInfo.Time < StrToTime&#40;'8 am'&#41;&#41; then 
  begin 
    HangUp; 
  end;
end
else
begin
  // on Saturday and Sunday
  HangUp; 
end;
This way you can test it using 'Test Action' and have it behave as expected.

You download the new version from the beta page:
http://ascendis.com/callerid/beta.php

Finest regards,
Bill Root
Ascendis Software
Post Reply