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
Why isn't this script working correctly?
Re: Why isn't this script working correctly?
Hi JT,
It looks like you were close! I think this will do what you need:
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
It looks like you were close! I think this will do what you need:
Code: Select all
// on Monday through Friday
if (DayOfWeek(Date) >= 2) and (DayOfWeek(Date) <= 6) then
begin
// if after 5 pm or before 8 am
if (Time > StrToTime('5 pm')) or (Time < StrToTime('8 am')) then
begin
HangUp;
end;
end
else
begin
// on Saturday and Sunday
HangUp;
end;
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
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
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
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
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
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:
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
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 (DayOfWeek(Date) >= 2) and (DayOfWeek(Date) <= 6) then
begin
// if after 5 pm or before 8 am
if (CallInfo.Time > StrToTime('5 pm')) or (CallInfo.Time < StrToTime('8 am')) then
begin
HangUp;
end;
end
else
begin
// on Saturday and Sunday
HangUp;
end;
You download the new version from the beta page:
http://ascendis.com/callerid/beta.php
Finest regards,
Bill Root
Ascendis Software