Script Exiting Unexpectedly

G

gregarican

A script I wrote checks incoming caller ID's against Microsoft
Outlook's Contact list. What I've found is that without explicitly
including a 'return' line in the conditional routine the script exits
unexpectedly. I've commented out the explicit return statement that's
required. Any ideas why this is the case? I'm using Ruby 1.8.2 on
Win32. I've traced the script and found that it doesn't bomb out with
any errors that I can tell. The only difference is the line that's
commented with HEADS-UP. Maybe I can't see the forest through the trees
:-/

outlookScreenPop.rb snippet
------------------------------------------

# My screen pop method
def screenPop(alertingCall)
allContacts = getContacts

# Continue with the screen pop query if data was passed back from the
Outlook OLE link.
if allContacts != nil
# Iterate through each contact to determine its associated telephone
numbers
allContacts.each do | contact |
cleanHomePhone = clean(contact.HomeTelephoneNumber)
cleanBusPhone = clean(contact.BusinessTelephoneNumber)
cleanCellPhone = clean(contact.MobileTelephoneNumber)

puts "#{Time.now.localtime.strftime("%m/%d/%Y @ %H:%M:%S")} -
Testing #{cleanHomePhone} | #{cleanBusPhone} | #{cleanCellPhone}
against #{alertingCall}."

# Match them up, append the entry to the logfile and display the
Contact Record
if alertingCall == cleanHomePhone or alertingCall == cleanBusPhone
or alertingCall == cleanCellPhone
puts "#{Time.now.localtime.strftime("%m/%d/%Y @ %H:%M:%S")} -
#{alertingCall} matched against #{contact.FullName} in Outlook
Contacts."
contact.Display
return
end
# HEADS-UP!!! Here's the explicit return statement that seems to be
necessary --- return
end
else
puts "#{Time.now.localtime.strftime("%m/%d/%Y @ %H:%M:%S")} - No
records found in Outlook Contacts or OLE link broken."
exit
end
end

# My loop that checks for incoming calls
begin
# Check the monitor every half second for an alerting call.
loop do
sleep 0.5
if @tsession.ringing?

# If the extension has an alerting call, collect the data.
@[email protected]
@[email protected]

# If the call isn't originating from the extension itelf, pop up a
Windows message box with the caller ID and attempt an Outlook Contact
screen pop.
if @callingNum != @extension
puts "#{Time.now.localtime.strftime("%m/%d/%Y @ %H:%M:%S")} -
#{@callingNum} calling."
Win32API.new("user32", "MessageBox", ['i','p','p','i'],
'i').call(0, "#{@callingNum} calling on
#{Time.now.localtime.strftime("%m/%d/%Y @ %H:%M:%S")}.", "Mojo CTI
Link", 0)
screenPop(@callingNum) if @callingNum != ""
end
end
end
ensure
@tsession.close
puts "#{Time.now.localtime.strftime("%m/%d/%Y @ %H:%M:%S")} - Closed
CTI stream from #{@extension}."
exit
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top