• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Weird choose from list behaviour
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Weird choose from list behaviour


  • Subject: Weird choose from list behaviour
  • From: Brian Christmas <email@hidden>
  • Date: Tue, 13 Nov 2012 23:00:40 +1100

G'day scripters.

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.

Any advice on what I'm doing wrong please?

Regards

Santa

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
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Weird choose from list behaviour
      • From: "koenig.yvan" <email@hidden>
    • Re: Weird choose from list behaviour
      • From: Luther Fuller <email@hidden>
    • Re: Weird choose from list behaviour
      • From: Axel Luttgens <email@hidden>
  • Prev by Date: Re: Out of Control Aliases?
  • Next by Date: Re: Weird choose from list behaviour
  • Previous by thread: Re: sort lines in TextWrangler
  • Next by thread: Re: Weird choose from list behaviour
  • Index(es):
    • Date
    • Thread