Announcement

Collapse
No announcement yet.

Script Error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bill Brower
    replied
    Here's mine, I don't think I ever touched it, it think it is virgin....


    HTML Code:
     
    Sub main
      'No action
    End Sub
    '************************************************************
    '* Process the Caller ID data passed by the WAF-NetCallerID
    '* script. 
    '* 
    '* Data is passed in 'what_parameters' in the following Format:
    '*	5/23/2003 <tab character> David Kindred <tab character> 3015551212
    '*	 (Date)					(Name)						(Number)
    '*
    '* This function splits the date, number and name components 
    '* of the CID data stream into their individual components
    '* and then shows some samples of what can be done with it.
    '*
    '* By default, only the example (Exampe 3) performing custom 
    '* announcements from the external file is active. Feel free 
    '* to uncomment other examples to make them functional.
    '************************************************************
    Function process_ncid_data(what_parameters)
      Dim s_paramaters
      Dim s_ncid_date
      Dim s_ncid_name
      Dim s_ncid_number
      Dim s_phone_list_name
      Dim s_phone_list_code
      Dim current_time
      
      'On Error Resume Next
      
      ' Split incoming data into component parts of 
      ' date, name and number.
      s_paramaters = split(what_parameters,Chr(9))
      s_ncid_date = s_paramaters(0)
      s_ncid_name = s_paramaters(1)
      s_ncid_number = s_paramaters(2)
      '--------------------------------------------
      ' Example 1: Announce name supplied by the
      '			NetCallerID unit.
      '--------------------------------------------
      'hs.Speak "Call from " & s_ncid_name
    
      '--------------------------------------------
      ' Example 2: Conditional processing based on 
      '			phone number
      '--------------------------------------------
      'Select Case s_ncid_number
      '
      '  Case "3015551111"
      '	' Custom household announcement.
      '	hs.Speak "Mom is calling"
      '
      '  Case "3015552222"
      '	' Turn on A1
      '	hs.ExecX10 "A1","on",0,0 
      '
      '  Case "3015553333"
      '	' Change the device string of A1
      '	hs.SetDeviceString "A1","Call from: " & s_ncid_name
      '
      'End Select
    
      '--------------------------------------------
      ' Example 3: Search phone list text file for
      '			number match. Return associated
      '			custom name and code. Based upon
      '			return code, caller is announced
      '			or not, depending upon time of
      '			day. 
      '--------------------------------------------
      ' Attempt to return custom name for caller from phone
      ' list file
      i_ret = find_match(s_ncid_number, s_phone_list_name, s_phone_list_code)   
      
      If i_ret = -1 Then
    	' No match was found in the phone list text file.
    	' Assign NCID name to phone list variable and 
    	' assign a code of 2000 (Others) to caller.
    	s_phone_list_name = s_ncid_name
    	s_phone_list_code = 2000
    	
    	' Add new caller to text file with a default
    	' code of 2000.
    	i_ret = add_caller_to_file(s_ncid_number, s_ncid_name, 2000)	 
      End If
      ' Create a version of time that does not include seconds. 
      ' Time is expressed in 24 hour format.
      current_time = datepart("h", time()) & ":" & right("0" & datepart("n", time()), 2)
    
      ' Conditionally announce callers.
      s_phone_list_code = cint(s_phone_list_code)
      Select Case True
    	Case (s_phone_list_code >= 1 and s_phone_list_code <= 999)
    	  ' Family -- announced 24/7
    	  hs.Speak "Family call from " & s_phone_list_name 
    	Case (s_phone_list_code >= 1000 and s_phone_list_code <= 1999)
    	  ' Friends -- announced 8AM - 10PM (note the space in " 8:00")
    	  If current_time >= " 8:00" And current_time <="22:00" Then
    		hs.Speak "Friend call from " & s_phone_list_name 
    	  End If
    	Case (s_phone_list_code >= 2000 and s_phone_list_code <= 2999)
    	  ' Others -- announced 10AM - 9PM
    	  If current_time >= "10:00" And current_time <="21:00" Then
    		hs.Speak "Other call from " & s_phone_list_name 
    	  End If
    	Case (s_phone_list_code >= 3000 and s_phone_list_code <= 3999)
    	  ' Solicitors -- not announced. Written to log.
    	  hs.writelog "Solicitor List", s_ncid_number & " " & s_phone_list_name
      End Select
    
      '--------------------------------------------
      ' Example 4: E-mail the CID Info. Using custom 
      '			announcement name, if the 
      '			Example 3 code above is active,
      '			and a match is found, otherwise
      '			send TelCo provided information.
      '			Customize To and From E-mail 
      '			addresses below.
      '--------------------------------------------
      'Dim s_to_email_address
      'Dim s_from_email_address
      'Dim s_email_subject
      'Dim s_email_body
      '
      's_to_email_address = "joe@schmoe.com"
      's_from_email_address = "joe@schmoe.com"
      's_email_subject = "Someone just called!"
      '
      ' Create the message body
      'If s_phone_list_name <> "" Then
      '  s_email_body = "Call from: " & s_phone_list_name
      'Else  
      '  s_email_body = "Call from: " & s_ncid_name  
      'End If
      's_email_body = s_email_body & vbcr & "Phone number: " & s_ncid_number & vbcr & "Date: " & s_ncid_date
      '
      ' Send the E-mail message
      'hs.SendEmail s_to_email_address, s_from_email_address, s_email_subject, s_email_body 
    
      '--------------------------------------------
      ' Example 5: Custom HS log entries.
      '			Write the CID data to the log in 
      '			any manner you desire.
      '--------------------------------------------
      'hs.WriteLog "WAF-NetCallerID", "Date: " & s_ncid_date & "  Name: " & s_ncid_name & "  Number: " & s_ncid_number
    
      '--------------------------------------------
      ' Example 6: Sends CID data to Krumpy's Audrey
      '			Server application. Related topics
      '			can be found at the following URL's:
      '
      '			http://homeseer.infopop.net/6/ubb.x?a=tpc&s=697298074&f=5082900573&m=9962913376&r=9962913376#9962913376
      '			http://homeseer.infopop.net/6/ubb.x?a=tpc&s=697298074&f=9352978952&m=5462904276&r=1822913376#1822913376
      '
      ' Thanks to Phil Clayton and srodgers for 
      ' this information.
      '--------------------------------------------
      'hs.Plugin("AudreyServer").SendCID cstr(s_phone_list_name),cstr(s_ncid_number) 
    End Function  
      
      
    '************************************************************
    '* Search the phone list file for a matching number. If found
    '* return the text to be announced and the code number 
    '* associated with the caller.
    '************************************************************
    Function find_match(what_number, what_name, what_phone_code)
      Dim fso
      Dim file
      Dim s_line
      Dim s_file_name
      Dim s_file_data
      
      find_match = -1
      
      ' Retrieve phone list file name from INI
      s_file_name = hs.GetINISetting ("Settings","s_phone_list_file","","WAF-NetCallerID.ini")
      
      Set fso = CreateObject("Scripting.FileSystemObject")
      Set file = fso.OpenTextFile(hs.GetAppPath & "\DATA\WAF-NetCallerID\" & s_file_name,1,True,0)
      ' Loop through phone list file
      Do While Not file.AtEndOfStream
    	s_line = file.ReadLine
    	' Ignore comment lines starting with ";"
    	If left(s_line,1) <> ";" Then
    	  s_file_data = split(s_line,Chr(9))
    	  
    	  ' Ensure that there are 3 data items
    	  If UBound(s_file_data) = 2 Then
    		
    		' Look for number match
    		If s_file_data(0) = what_number Then 
    		  ' Match found. Assign custom name and
    		  ' code values and exit function.
    		  what_phone_code = s_file_data(1)
    		  what_name = s_file_data(2)
    		  find_match = 0 
    		  Exit Do
    		End If
    	  
    	  End If
    	
    	End If
      Loop
      
      ' Clean up
      file.Close
      Set file = Nothing
      Set fso = Nothing
    End Function
    
    '************************************************************
    '* Add the caller's name and number to the end of the phone
    '* list file.
    '************************************************************
    Function add_caller_to_file(what_number, what_name, what_phone_code)	 
      Dim fso
      Dim file
      Dim s_line
      Dim s_file_name
      Dim s_file_data
      
      add_caller_to_file = -1
      
      ' Retrieve phone list file name from INI
      s_file_name = hs.GetINISetting ("Settings","s_phone_list_file","","WAF-NetCallerID.ini")
      
      Set fso = CreateObject("Scripting.FileSystemObject")
      
      ' Check to see if file exists. If not, create it.
      If Not fso.FileExists(s_file_name) Then
    	Set file = fso.CreateTextFile(s_file_name)
      End If
      ' Open the file for writing.
      Set file = fso.OpenTextFile(hs.GetAppPath & "\DATA\WAF-NetCallerID\" & s_file_name,8,True)  
      
      ' Write the CID data to the phone list text
      ' file in the following format:
      ' Phone Number <Tab character> Phone Group Code <Tab character> Telco Provided Name
      file.WriteLine what_number & Chr(9) & what_phone_code & Chr(9) & what_name
      add_caller_to_file = 0
      
      ' Notify user that name has been added to the file.
      hs.Speak "A new number has been added to the phone list."
      
      ' Clean up
      file.Close
      Set file = Nothing
      Set fso = Nothing
    End Function
    
     

    Leave a comment:


  • Guest's Avatar
    Guest started a topic Script Error

    Script Error

    I am having issue with the CID when I only get a number with no name. What I see is the name of the last caller with the correct number.

    I modified the script that came with WAF and set the Ini file, but I am getting an error and need help.

    This is the error message "Running script, script run or compile error in file: WAF-NetCallerID-CID-Processing.vbs1002:Syntax error in line 19 More info: Syntax error"

    Line 19 is the Function "process_ncid_data(what_parameters)".

    This is the script "

    Sub main
    '*********************************************************** *
    '* Process the Caller ID data passed by the WAF-NetCallerID
    '* script.
    '*
    '* Data is passed in 'what_parameters' in the following Format:
    '* 5/23/2003 <tab character> David Kindred <tab character> 3015551212
    '* (Date) (Name) (Number)
    '*
    '* This function splits the date, number and name components
    '* of the CID data stream into their individual components
    '* and then shows some samples of what can be done with it.
    '*
    '* By default, only the example (Exampe 3) performing custom
    '* announcements from the external file is active. Feel free
    '* to uncomment other examples to make them functional.
    '*********************************************************** *
    Function process_ncid_data(what_parameters)
    Dim s_paramaters
    Dim s_ncid_date
    Dim s_ncid_name
    Dim s_ncid_number
    Dim s_phone_list_name
    Dim s_phone_list_code
    Dim current_time
    Dim s_temp

    On Error Resume Next

    ' Split incoming data into component parts of
    ' date, name and number.
    s_paramaters = split(what_parameters,Chr(9))
    s_ncid_date = s_paramaters(0)
    s_ncid_name = s_paramaters(1)
    s_ncid_number = s_paramaters(2)
    'Added 3/11/06
    If s_ncid_name = "Wireless Calle" Then
    s_ncid_name = "None"
    End If
    'End add
    end function
    end Sub
Working...
X