Dialectic Preprocess Number

Introduction
You can preprocess a number using an AppleScript before the rest of the Dialing rules are applied. In this way you could strip the local country code, strip formatting, apply your own search and replace routines, etc. to the number to be dialed. Once processed by your script, the number is then run through the current Dialing Rules. To use this feature, simply create a new AppleScript in the Script Editor (or the AppleScript IDE of your choice) and include the following subroutine (adding your own preprocessing code, of course):

on handle_preprocess_number_action(the_number)
	
	--apply your preprocessing code here
	
	return the_number
end handle_preprocess_number_action

Save your script as a compiled AppleScript. Then, from the Dialing Rules preference window, enable the option to “Preprocess Number Using AppleScript:” and, at the prompt, select the compiled script you saved. Now, whenever you ask Dialectic to dial a number, the number will be processed by your script and then the text result returned by the script will be further transformed by the current Dialing Rules.

If you want to do your entire transformation in the preprocessing script and not process the number by the rest of the Dialing Rules, you can modify the “handle_preprocess_number_action” handler to return a two item list:

on handle_preprocess_number_action(the_number)
	
	--apply your preprocessing code here
	
	return {false, the_number}
end handle_preprocess_number_action

If you do return a list, the first item must be a boolean that tells Dialectic whether the transformed number should be further processed by the current Dialing Rules (true) or if the transformation done by the script is all the modification necessary and the number should be used as returned from the script (false). The second item in the returned list must be the transformed number. If you do return a list with the first value as false (meaning you do not want the Dialing Rules to further process the number), the call type will be identified as “Literal” and dialed using the Dial Method configuration specified in the Literal call type settings in your current Location.

See the included example scripts for ways in which you can preprocess your numbers.

Your choice of script to use as a preprocessor is linked to the Location so you can have different scripts associated with different Locations. In this way you could determine if you were at home, and, as such, strip local area codes from your numbers or, if your were on the road, make sure your numbers always include the area code.

Any feedback you may have is appreciated.

Requirements
Mac OS X 10.4 or later & Dialectic

Warranty
This software is provided on an “AS IS” basis, without warranty of any kind, either expressed or implied, including, without limitation, warranties that the subject software is free of defects, merchantable, fit for a particular purpose or non-infringing. JNSoftware LLC assumes no risk as to the quality and performance of the software. Should the software prove defective in any respect, JNSoftware LLC assumes no cost or liability for any servicing, repair or correction. This disclaimer of warranty constitutes an essential part of this license. No use of any subject software is authorized hereunder except under this disclaimer.

Under no circumstances and under no legal theory, whether tort (including, without limitation, negligence or strict liability), contract, or otherwise, shall JNSoftware LLC be liable for any direct, indirect, special, incidental, or consequential damages of any character with respect to the software including, without limitation, damages for loss of goodwill, work stoppage, loss of data, computer failure or malfunction, or any and all other commercial damages or losses, even if JNSoftware LLC shall have been informed of the possibility of such damages. This limitation of liability shall not apply to liability resulting from JNSoftware LLC’s negligence to the extent applicable law prohibits such limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so that exclusion and limitation may not apply to you.

You may distribute this software so long as you distribute the complete package including this Read Me document.

Copyright © 2011 JNSoftware LLC. All Rights Reserved.