Entourage script for discussion boards

Hi! I really hope someone can help me with this, I am driving myself nuts. I found this script on a help discussion board copied and pasted into script editor and have removed hard returns but it keeps getting hung up on the seventh line (“Comma” then). It gives me the error when checking syntax…Expected end of line but found “then”.
Can anyone help me with this? What it means? What I am supposed to do?
I aprreciate it! Thanks!

tell application "Microsoft Entourage" 
 display dialog "Do you want to include a comma, as" & return & return & "   LastName, FirstName" & return & return & "or no comma, as" & return & return & "   LastName FirstName" buttons {"Cancel", "No Comma", "Comma"} with icon 1  
 if button returned of result  
 "Comma" then 
         set ifComma to ", " 
 else 
     set ifComma to " " 
 end if 

    set allContacts to every contact 
 repeat with theContact in allContacts 
     tell theContact 
         set {fName, lName} to {first name as Unicode text, last name as 
 Unicode text} 
         if fName  "" and lName  "" then 
             set nickname to (lName & ifComma & fName) 
         else if lName  "" then 
             set nickname to lName 
         else if fName  "" then 
             set nickname to fName 
         else if company  "" then 
             set nickname to company 
         else if (every email address of it)  {} then 
             set nickname to contents of default email address 
         end if 
     end tell 
 end repeat 

    beep 
 display dialog "All done!" & return & return & "Now add Nickname 
 column in View menu/Columns in the Address Book, and click its header to 
 sort 
 by nickname." buttons {"OK"} default button 1 with icon 1 

end tell

I can’t be certain, but it looks to be as if the code is missing an equals sign (or something similar).

if button returned of result = "Comma" then

I don’t think ‘button returned’ is a boolean.

mgh

I think this is what you want:

tell application "Microsoft Entourage"
    activate
    display dialog "Do you want to include a comma, as" & return & return & "  LastName, FirstName" & return & return & "or no comma, as" & return & return & "  LastName FirstName" buttons {"Cancel", "No Comma", "Comma"} with icon 1
    set ifComma to " "
    if button returned of result = "Comma" then set ifComma to ", "
    
    set allContacts to every contact
    repeat with theContact in allContacts
        tell theContact
            set {fName, lName} to {first name as Unicode text, last name as Unicode text}
            if fName is not "" and lName is not "" then
                set nickname to (lName & ifComma & fName)
            else if lName is not "" then
                set nickname to lName
            else if fName is not "" then
                set nickname to fName
            else if company is not "" then
                set nickname to company
            else if (every email address of it) is not {} then
                set nickname to contents of default email address
            end if
        end tell
    end repeat
    
    beep
    display dialog "All done!" & return & return & "Now add Nickname column in View menu/Columns in the Address Book, and click its header to sort by nickname." buttons {"OK"} default button 1 with icon 1
end tell

Jon