Can someone please tell me WHY this script does not work in panther, yet works fine in Tiger???
Everything works fine except for the “if companyinfo is true” section… It says “No Result was returned from some part of this expression”… and if I change the syntax to read:
if (first name of theNames) as string ≠missing value then
set firstname to (first name of theNames)
set hasfirstname to true
else
set firstname to “”
set hasfirstname to false
end if
then I get “firstname is not defined” !!!
Both of these ways work perfectly fine in tiger… someone please help me with this nonsense!
[code]set emaildata to {}
set groupdata to {}
set compilationList to “”
set totalskip to 0
set thebook to {}
set totalcount to 0
set theNames to “”
set thebook to getpeople()
set totalcount to (count thebook)
set successful to 0
repeat with theNames in thebook
my gatherdata(theNames, compilationList, totalskip, successful)
set {compilationList, totalskip, successful} to the result
end repeat
display dialog “converted " & successful & " email addresses and skipped " & totalskip & " items” & " out of " & totalcount
set docName to choose file with prompt “Choose pine addressbook file” default location (path to home folder) with invisibles
set docPointer to (open for access docName with write permission)
set eof of docPointer to 0
write compilationList to docPointer as «class utf8»
close access docPointer
display dialog “complete!”
on getpeople()
tell application “Address Book”
activate
return every person as list
end tell
end getpeople
on gatherdata(theNames, compilationList, totalskip, successful)
set emaildata to {}
set groupdata to {}
tell application "Address Book"
set theEmails to {}
set thegroups to {}
set finalemail to "("
set finalgroup to ""
set currentemail to 0
set currentgroup to 0
set commentfield to ""
set nickfield to ""
set fcc to ""
set companyinfo to the (company of theNames)
set namefield to the (name of theNames)
set emaildata to the (email of theNames)
set companydata to the (organization of theNames)
set companydatat to the (organization of theNames) as string
set groupdata to the (group of theNames)
set notedata to the (note of theNames)
set notedatat to notedata as string
if companyinfo is true then
set namefield to ""
if suffix of theNames is not missing value then
set suffixname to (suffix of theNames)
set hassuffix to true
else
set suffixname to ""
set hassuffix to false
end if
if first name of theNames is not missing value then
set firstname to (first name of theNames)
set hasfirstname to true
else
set firstname to ""
set hasfirstname to false
end if
if middle name of theNames is not missing value then
set middlename to (middle name of theNames)
set hasmiddlename to true
else
set middlename to ""
set hasmiddlename to false
end if
if last name of theNames is not missing value then
set lastname to (last name of theNames)
set haslastname to true
else
set lastname to ""
set haslastname to false
end if
(* prefix = company on company check
set prefix to namefield
if hasprefix and hasfirstname then
set namefield to namefield & space
end if
*)
set namefield to namefield & firstname
if hasfirstname and hasmiddlename then
set namefield to namefield & space
end if
set namefield to namefield & middlename
if hasmiddlename and haslastname then
set namefield to namefield & space
end if
set namefield to namefield & lastname
if haslastname and hassuffix then
set namefield to namefield & space
end if
set namefield to namefield & suffixname
end if
if notedata is not missing value then
set AppleScript's text item delimiters to "
"
set temp to text items of notedata
set AppleScript’s text item delimiters to space
set notedata to temp’s text items as string
set AppleScript’s text item delimiters to “”
set commentfield to notedata
end if
if companydata is not missing value then
set AppleScript’s text item delimiters to " "
set temp to text items of companydata
set AppleScript’s text item delimiters to “_”
set companydata to temp’s text items as string
set AppleScript’s text item delimiters to “”
set nickfield to companydata
end if
if emaildata ≠{} then
repeat with thisEmailRecord in emaildata
copy the value of thisEmailRecord to the end of theEmails
end repeat
set emailnumbers to count theEmails
if emailnumbers > 1 then
repeat emailnumbers times
set currentemail to currentemail + 1
set finalemail to (finalemail & item currentemail of theEmails as string)
if currentemail ≠emailnumbers then
set finalemail to finalemail & ","
end if
end repeat
set finalemail to finalemail & ")"
else
set finalemail to theEmails as string
end if
-- pine .addressbook format = nick, name, email, fcc, comment
set pineline to nickfield & tab & namefield & tab & finalemail & tab & fcc & tab & commentfield
set compilationList to compilationList & pineline & "
"
set successful to successful + 1
else
set totalskip to totalskip + 1
end if
end tell
return {compilationList, totalskip, successful}
end gatherdata[/code]