Re: Postcode validation UK (QAS)

Here's the code I used. Any questions probably best asked in this forum then I
can answer for everyone.

Note that my search string is made up of "(house name or number), (postcode)".
I don't allow anything else. You can obviously tweak to suit.

Code works (for me) without a hitch on Win2K platform but experience
intermittent errors giving rise to "API not initialised" error code from QAS on
Win2003 platform. Currently investigating this - seems to occur overnight only
and is got rid of by bouncing the server. At the moment it's only an
inconvenience. Therefore think that relates to the server, rather than the code.

Note also with Win2003 you MUST close the object at the end : Win2K is more
forgiving and seems not to mind if you miss that line out.

<CFTRY>
<CFOBJECT ACTION="CONNECT" CLASS="QAProWeb.QAProWeb.1" NAME="objQAddress"
TYPE="COM">
<CFCATCH>
<CFOBJECT ACTION="CREATE" CLASS="QAProWeb.QAProWeb.1"
NAME="objQAddress" TYPE="COM">
</CFCATCH>
</CFTRY>
<!--- Now do the search based on the search terms sent to us in the FORM
variables above --->
<cfscript>
// Open the QAS object
iResult="";
iCode = objQAddress.Open("QAProWeb","QADefault");
// Get any status code from QAS - see QAS manual for descriptions of codes
qasStatus1 = objQAddress.ErrorMessage(iCode);
//Depending on whether this was a postcode or street/town search do correct
one
iCode1 = objQAddress.Search("#SearchString#");
// Again get status variable on the search
qasStatus2 = objQAddress.ErrorMessage(iCode);
// Set variable to number of results returned
iResultCount = objQAddress.ResultsCount - 1;
sEncodedAddress = "";
// Get the 'Preview' Address
iCount=0;
sPreviewAddress = objQAddress.Preview(iCount);
// Get the actual full address value
sAddCount=0;
//line below is the version for one property only
//sAddress=objQAddress.Address(0);
//this loops through the properties and extracts each one.
for(iLine=1; iLine LTE (iResultCount+1); iLine=iLine+1)
{sAddress[iLine] = objQAddress.Address(iLine-1); }
objQAddress.Close();
</cfscript>