DNW66 Posted November 17, 2016 #1 Share Posted November 17, 2016 I have been searching for a script to this as I am not fluent in VB. I have found the following from Tom Wellige in the old forum pages, but am not sure what to put in the evaluate block to get this to work. Also what format do the numbers need to be in the text document? Function Checkcaller ( callerID ) Const filename = "c:\scripts\blocked.txt" Dim bFound Dim fso, file bFound = False Set fso = CreateObject("Scripting.FileSystemObject") If fso.FileExists( filename ) Then Set file = fso.OpenTextFile( filename, 1, False, 0) Do While (Not file.AtEndOfStream) And (Not bFound) If InStr(file.ReadLine, PBXCall.CallingPartyNumber) <> 0 Then bFound = True Loop file.Close Set file = Nothing End If Set fso = Nothing Checkcaller = bFound End Function thanks in advance Link to comment Share on other sites More sharing options...
Most Valued User ogoettlich Posted November 18, 2016 Most Valued User #2 Share Posted November 18, 2016 Hi, the PBXCall.CallingPartyNumber should be canonical. Have a look here. To have a look at return, you should have a look in your "IpPbxSrv___.log" file, by using following example in your script. PBXScript.OutputTrace "my text: " & variable Another example using XML, including the schema of it. You could adopt it for your use case. Dim xmlDoc Dim objNode Dim colNodes Dim infoFound Dim infoText '<?xml version='1.0'?> '<infos> ' <info>abc</info> ' <info>def</info> ' <info>ghi</info> '</infos> Set xmlDoc = _ CreateObject("Microsoft.XMLDOM") xmlDoc.Async = "False" xmlDoc.Load("C:\Path\xyz.xml") 'your Path to XML Set colNodes=xmlDoc.selectNodes _ ("//infos/info") infoFound = "false" 'Loop For Each objNode in colNodes If objNode.Text = "abc" Then infoFound = "true" infoText = objNode.Text PBXScript.OutputTrace "Info found: " & infoText Else ' nothing End If Next If infoFound = "true" Then UseExit = 0 Else UseExit = 1 End If Link to comment Share on other sites More sharing options...
DNW66 Posted November 18, 2016 Author #3 Share Posted November 18, 2016 Thank you for your reply. I did this in the end...... ' FileOpen iomode Values Const fsoForReading = 1 Const fsoForWriting = 2 Const fsoForAppending = 8 ' Bankholiday Filename Const sBHFilename = "bankholiday.txt" Function IsBlockedNum ( vNum ) Dim wsh, fso, file Dim sDir, sFile, sLine Dim bReturn, nPos bReturn = False sFile = "C:\Scripts\blockednumbers.txt" ' Create FileSystemObejct Set fso = CreateObject("Scripting.FileSystemObject") ' Open text file Set file = fso.OpenTextFile(sFile, fsoForReading) do while (not (file.AtEndOfStream)) and (not bReturn) sLine = file.ReadLine if sLine = vNum then bReturn = True loop file.Close Set file = Nothing Set fso = Nothing IsBlockedNum = bReturn End Function I then used "IsBlockedNum (IpPbx.CallingNumber)" in the Evaluate block. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.