Postcode Lite Software providing Royal mail PAF data

Programmers SDK : Get Premises Level Address

Getting the address at premises level is a two stage process.  First we get the list of addresses at a postcode, to display to the user.  When the user selects the address, we can then retrieve the full address data from the Postcode Lite server or local data file.

Stage 1 : Get the address lines to display

Function : GetStreetAddress(Postcode as string, DataKey as string, Location as string, Parms as string) as string

Parameter Description
Postcode Postcode you are trying to find
DataKey For Internet based data, use your data key, assigned when you opened an account.

When Postcode Lite is used within an organisation use the data key beginning with "I", and buy User licenses to access the data.
When supplying the address data to the general public, on a web site, use the data key beginning with "W" and purchase Web Credit Packs.


Location For Local Data, specify the location of the data files.
For example "C:\MyApp".  The correct license is assigned as part of the unlock process when using local data.
Parms This is for future expansion

Returns:

This function returns true if search returned valid data, else .General_errormessage will contain the error, and .General_credits_display_text if problem with license.

This PostCodeLite Object contains the following properties:

Property Description
General_errormessage Error Message if error
General_credits_display_text Number of Credits/Users available

We then call .GetFullAddressLineForSelection() to get each line to display, and keep the PostcodeLite object alive, since it knows the ID's which match the lines displayed.

Example code : Visual Basic :

Dim PostCodeLite As Object, ReturnedData as string

 

Set PostCodeLite = CreateObject("IPostCodeLite.PostCode")

With PostCodeLite
  List.clear
  PostcodeToSearchFor = "PE13 2QL"
  If .GetFullAddressToList (PostcodeToSearchFor,"I_HDI7...HU7ID","","") Then
    'Process data
    Line = .GetFullAddressLineForSelection()


    do until Line = ""

      'Add each line to list box
      list.AddItem (Line)
      Line = .GetFullAddressLineForSelection()
    loop
  Else

    If .General_errormessage <> "" Then

       'Show/Handle any errors
       MsgBox .General_credits_display_text & vbCrLf & .General_errormessage, _

                    vbCritical, "Postcode Lite"
    Else
       MsgBox "Not found!"
    End If
  End If

  'Show Credit/License in form caption
  Me.Caption = .General_credits_display_text
End With

 

'Note : we keep the object alive for next part of search

 

Stage 2 : Get the address information for selected line

Function : GetFullAddressRecord(SelectedListIndex as long) as string

Parameter Description
SelectedListIndex The index of the line chosen.  0 for the first line.

Returns:

This function returns true if search returned valid data, else .General_errormessage will contain the error, and .General_credits_display_text if problem with license.

This PostCodeLite Object contains the following properties:

Property Description
General_errormessage Error Message if error
General_credits_display_text Number of Credits/Users available
Address_Organisation
Address_Line1
Address_Line2
Address_Line3
Address_Town
Address_County
Address_Postcode
Address_Country
These properties contain the correctly formatted address record.

Example code : Visual Basic :

 

With PostCodeLite
  SelectedListIndex = list.ListIndex
  If .GetFullAddressRecord (SelectedListIndex) Then
    'Process data

    Dim DataToShow$
    DataToShow = "Data Returned : " & vbCrLf
    DataToShow = DataToShow & " Status : " & .General_credits_display_text & vbCrLf
    DataToShow = DataToShow & " accountadminpage : " & .General_accountadminpage & vbCrLf
    DataToShow = DataToShow & "" & vbCrLf
    DataToShow = DataToShow & " Company : " & .Address_Organisation & vbCrLf
    DataToShow = DataToShow & " line1 : " & .Address_Line1 & vbCrLf
    DataToShow = DataToShow & " line2 : " & .Address_Line2 & vbCrLf
    DataToShow = DataToShow & " line3 : " & .Address_Line3 & vbCrLf
    DataToShow = DataToShow & " town : " & .Address_Town & vbCrLf
    DataToShow = DataToShow & " county : " & .Address_County & vbCrLf
    DataToShow = DataToShow & " postcode : " & .Address_Postcode & vbCrLf
    DataToShow = DataToShow & " country : " & .Address_Country & vbCrLf
    msgbox DataToShow

  Else
    'Show/Handle any errors
    MsgBox .General_credits_display_text & vbCrLf & .General_errormessage, vbCritical,
          "Postcode Lite"
  End If

  'Show Credit/License in form caption
  Me.Caption = .General_credits_display_text
End With

Set PostCodeLite = Nothing

 

 

 
Postcode Lite is brought to you by ComTek Accounts Ltd