;CALLID.WAS v1.0 To Capture Caller ID Name and Number ;***************************************************************************** ;* * ;* CALLID.WAS * ;* Copyright (C) 1996 Datastorm Technologies, Inc. * ;* All rights reserved. * ;* * ;* This program captures Caller ID information between the first and second * ;* ring and places that information in the Caller ID Database file. From * ;* there, the information is available to edit in the Caller ID Database * ;* Editor. * ;* * ;* This ASPECT SCRIPT is intended only as a sample of ASPECT programming. * ;* DATASTORM makes no warranty of any kind, express or implied, including * ;* without limitation, any warranties of merchantability and/or fitness * ;* for a particular purpose. Use of this program is at your own risk. * ;***************************************************************************** ;***************************************************************************** ;* MACRO DEFINITIONS * ;***************************************************************************** #define CaptureFilePath "C:\" ;Path for the capture file #define CaptureFileName "PW3.CAP" ;Filename for the capture file #define DefaultPath "C:\PROWIN3\" ;Default directory for Prowin3 #define NameField "name" ;Caller ID Name Identyfier #define NumberField "nmbr" ;Caller ID Number Identyfier #define VK_ESCAPE 0x1B ;Esc or Escape key ;***************************************************************************** ;* GLOBAL VARIABLES * ;***************************************************************************** string CallerIdNameInfo="", DBFilename, CaptureFileToOpen="" ;***************************************************************************** ;* * ;* MAIN * ;* The MAIN Procedure will setup the environment for the script. It will * ;* then ask the user if they would like the script to run once or continually* ;* Depending on the user's selection it will run once, or run continually. * ;* It then calls the CleanUp procedure to restore the user's original * ;* settings. * ;* * ;* Calls: SetupForScript, MonitorPort, CleanUp * ;* * ;* * ;***************************************************************************** proc Main integer CallerIdOnOff=0, ButtonPress=0, PressedKey string OrginalCaptureFilePath, OrginalCaptureFileName SetupForScript(&CallerIdOnOff, &OrginalCaptureFilePath, &OrginalCaptureFileName) ;calls SetupForScript strinsert DBFilename Defaultpath 0 ;sets variable for caller id strinsert CaptureFileToOpen CaptureFileName 0 ;inserts the path and strinsert CaptureFileToOpen CaptureFilePath 0 ;file into onestring. sdlgmsgbox "Caller ID" "Do you wish the script to run continuously" QUESTION YESNO ButtonPress 1 if ButtonPress==6 while 1 clear keyget PressedKey ;Monitor port until the if PressedKey==VK_ESCAPE ;user pressed the escape exitwhile ;key. endif MonitorPort() endwhile else MonitorPort() endif Cleanup(&CallerIdOnOff, &OrginalCaptureFilePath, &OrginalCaptureFileName) ;calls the Cleanup procedure endproc ;***************************************************************************** ;* * ;* MonitorPort * ;* This procedure MonitorPort monitors the port for incoming Caller * ;* ID information. * ;* * ;* Calls:Checkname, CleanUp * ;* Called by: Main * ;* Modifies globals: None * ;* * ;***************************************************************************** proc MonitorPort waitfor "ring" FOREVER capture on ;turn capture file on waitfor "ring" FOREVER capture off ;turn capture file off if fopen 0 CaptureFileToOpen READ TEXT ;opens capture file CheckName() ;calls the CheckName else ;procedure usermsg "Capture File is not open" endif endproc ;***************************************************************************** ;* * ;* CHECKNAME * ;* This procedure CheckName checks the capture file for the name in the * ;* caller id information that was captured between the first and second ring.* ;* * ;* Calls:CHECKNUMBER * ;* Called by: Main, RunForever * ;* Modifies globals: None * ;* * ;***************************************************************************** proc CheckName integer CharactersToCompare=4 while not feof 0 ;If not end of file continue fgets 0 CallerIdNameInfo ;Gets string of data from ;Capture file. if strnicmp NameField CallerIdNameInfo CharactersToCompare ;checks the exitwhile ;string for name endif endwhile CheckNumber(CharactersToCompare) ;calls the CheckNumber procedure endproc ;***************************************************************************** ;* * ;* CHECKNUMBER * ;* The procedure CheckNumber checks the capture file for the number in the * ;* caller id information that was captured between the first and second ring * ;* * ;* Calls: WriteInfo * ;* Called by: CheckName * ;* Modifies globals: None * ;* * ;***************************************************************************** proc CheckNumber param integer CharactersToCompare string CallerIdNumberInfo="" rewind 0 ;reset counter to beginning of file while not feof 0 ;if not end of file continue fgets 0 CallerIdNumberInfo ;gets string of data from ;capture file if strnicmp NumberField CallerIdNumberInfo CharactersToCompare ;checks string number fclose 0 ;close the capture file exitwhile endif endwhile WriteInfo(&CallerIdNumberInfo, CharactersToCompare) ;calls the WriteInfo procedure endproc ;***************************************************************************** ;* * ;* WRITEINFO * ;* The procedure WriteInfo checks to make sure that there is information in * ;* the two global variables CallerIdNameInf and CallerIdNumberInfo, and if * ;* not adds the approporiate information. Then writes the information to * ;* the caller id database file. * ;* * ;* Calls: EndOfFile * ;* Called by: CheckNumber * ;* Modifies globals: CallerIdNameInfo * ;* * ;***************************************************************************** proc WriteInfo param string CallerIdNumberInfo param integer CharactersToCompare integer CharactersInName=0, CharactersInNumber=0 integer RecordCounter, NewRecordCounter integer NumberToWrite=0, NameToWrite=0 integer HappyFace='`x001', BlankNullSpace='`x000' if strnicmp "name" CallerIdNameInfo CharactersToCompare ;checks to see if a name was sent strdelete CallerIdNameInfo 0 5 ;deletes the first 5 characters else CallerIdNameInfo="No Name Sent" ;if no name sent fills variable endif if strnicmp "nmbr" CallerIdNumberInfo CharactersToCompare ;checks to see if number was sent strdelete CallerIdNumberInfo 0 5 ;deletes the first 5 characters else CallerIdNumberInfo="No Number Sent" ;if no number sent fills variable endif strlen CallerIdNameInfo CharactersInName ;finds the length of the string strdelete CallerIdNameInfo CharactersInName 2 ;deletes last 2 characters ;in variable NameToWrite = 41-0 ;how many characters to write ;to the file strlen CallerIdNumberInfo CharactersInNumber ;finds length of the string strdelete CallerIdNumberInfo CharactersInNumber 9 ;deletes the last character ;in the variable NumberToWrite = 41-0 ;how many characters to write ;to the file ;file name if fopen 1 DBFilename READWRITE TEXT ;opens the caller id file fgetc 1 RecordCounter ;reads the first byte from ;the file NewRecordCounter = RecordCounter + 1 ;increments the byte by one rewind 1 ;returns file pointer to ;begining of file fputc 1 NewRecordCounter ;writes the incremented buty to ;the file fseek 1 15 0 ;puts file pointer at position 15 finsblock 1 712 ;inserts a 712 byte block of ;space in the file fwrite 1 HappyFace ;writes beginning of record marker fwrite 1 BlankNullSpace ;adds blank space to the file fwrite 1 CallerIdNameInfo NameToWrite ;writes name information to file fwrite 1 CallerIdNumberInfo NumberToWrite ;writes nmbr information to file EndOfFile(BlankNullSpace) ;calls the EndOfFile procedure fclose 1 ;closes the caller id file else usermsg "Database file could not open" endif endproc ;***************************************************************************** ;* * ;* ENDOFFILE * ;* The procedure EndOfFile adds nulls to the end of the file to set the * ;* record to the correct length. * ;* * ;* * ;* Called by: WriteInfo * ;* * ;* * ;***************************************************************************** proc EndOfFile param integer BlankNullSpace integer Passes=0 ;Fills rest of the record with ;nulls, so the file is the ;correct length for Passes = 0 upto 312 fwrite 1 BlankNullSpace endfor endproc ;***************************************************************************** ;* * ;* SetupForScript * ;* The procedure SetupForScript setups the script by reading the current * ;* setup and the changing the options I need set for the script to run * ;* correctly * ;* * ;* Called by: Main * ;* Modifies globals: None * ;* * ;***************************************************************************** proc SetupForScript param integer CallerIdOnOff param string OrginalCaptureFilePath, OrginalCaptureFileName fetch capture file OrginalCaptureFileName ;Checks to see how pw3 ;is setup and stores fetch capture path OrginalCaptureFilePath ;that information. Then ;sets up pw3 to run fetch callerid addcallinfo CallerIdOnOff ;the script. fetch callerid database DBFilename set callerid ON set callerid addcallinfo OFF set capture file CaptureFileName set capture path CaptureFilePath set capture recordmode SCREEN set capture overwrite ON set aspect spawn ON endproc ;***************************************************************************** ;* * ;* CLEANUP * ;* The procedure CleanUp deletes the capture file I created and also resets * ;* the capture file and paths I needed to change for the script. * ;* * ;* Called by: Main * ;* * ;***************************************************************************** proc CleanUp param integer CallerIdOnOff param string OrginalCaptureFilePath, OrginalCaptureFileName delfile CaptureFileToOpen ;resets pw3 to the way the ;customer had it set up set capture path OrginalCaptureFilePath ;and deletes the capture file. set capture file OrginalCaptureFileName set callerid addcallinfo CallerIdOnOff endproc