Need script to put company name in the last name field of contact

Hi all. I am new to the mac world and obviously new to scripting. I have wrestled with this script for the last couple of days and am still not able to get it to run appropriately. I am using entourage as my contact manager.

I have a lot of contacts that just contain a company name with no related personal conatct information. I sync my contacts to my phone however my phone will not search on company, just the first name, last name field. So i was trying to write a script to copy the company name to the last name field as long as the first name and last name fields are empty. I tried to modify a script that was to check for duplicate contacts however I have been unsuccessfull in getting it to run correctly.

Any help greatly appreciated :smiley: