Have I missed out on seeing reports of a problem with the 'Choose from list' command?
I've never had to use it before, but the following works when trying to quit with the Cancel button, until I actually choose an item from the list, then it fails to quit, instead going to the part of the script following the 'else' statement, and uses the first item of the list. It says 'false' but refuses to acknowledge 'false' exists.
property MailManagerDesktopFolder : "Mail Manager Folder"
property PathToDesktop : path to desktop as text
property MailManagerDesktopFolderPath : PathToDesktop & MailManagerDesktopFolder as text
on run
my dataEntry()
end run
on dataEntry()
set theAnswer to ""
set TheMainMenu to {"Main Mail Recipient", "Hourly Report CC Recipients", "Daily Report CC Recipients", "Preparation Problem CC Recipients", "Emergency Contact", "Emergency Contact CC Recipients"}
set theAnswer to choose from list TheMainMenu with prompt "Select an eMail group in which you wish to add or delete a recipient." & return with title "Mail Manager eMail lists"
say theAnswer
if theAnswer as text = "false" then # This gets ignored once a list item is selected, but it says 'false'
quit me
else
set theFileName to " " & theAnswer as text
set theWholeList to my ReadFile3(theFileName)
if theAnswer as text = "Main Mail Recipient" then
my Entry1(theFileName, theWholeList, theAnswer)
end if
end if
end dataEntry
on Entry1(theFileName, theWholeList, theAnswer)
set theSecondMenu to theAnswer & return & return & {theWholeList}
set thePrompt to "Enter an Email address in the form…" &
return &
return & "BC<
email@hidden>"
set theOKName to "Change"
if theWholeList = "" then
set theSecondMenu to my EnterARecipient(theWholeList, theAnswer)
my WriteFile(theFileName, theSecondMenu)
end if
display dialog ((theSecondMenu & return & return & thePrompt) as text) & return default answer theWholeList buttons {"Change this name", "Back to Main Menu"} with title theAnswer
set theAnswer2 to the result
set tempReturned to text returned of theAnswer2
if tempReturned = "" then my Entry1(theFileName, theWholeList, theAnswer)
if button returned of theAnswer2 = "Back to Main Menu" then my dataEntry()
set thewholelist2 to {}
set end of thewholelist2 to tempReturned --my EnterARecipient(theSecondMenu, theAnswer)
my WriteFile(theFileName, thewholelist2)
my Entry1(theFileName, thewholelist2, theAnswer)
end Entry1
on EnterARecipient(theTitle, theAnswer)
display dialog "Please enter a " &
theAnswer & " in the form…" &
return &
return & "BC<
email@hidden>" &
return default answer theTitle set thetext to text returned of the result
if thetext = "" then my EnterARecipient(theTitle)
return thetext
end EnterARecipient
on ReadFile3(theFileName)
try
set TheFileNameTemp to (MailManagerDesktopFolderPath & ":" & theFileName) as text
set wholelist to read file (TheFileNameTemp) using delimiter ","
return wholelist
on error errmsg
return ""
end try
end ReadFile3
on WriteFile(theFileName, TheWriteItem)
set theFileName to (MailManagerDesktopFolderPath & ":" & theFileName) as string
set fRef to (open for access file theFileName with write permission)
set eof fRef to 0
try
write (item 1 of TheWriteItem as string) & "," to fRef
repeat with x from 2 to number of items in TheWriteItem
write item x of TheWriteItem & "," to fRef
end repeat
end try
close access fRef
end WriteFile