• 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
Re: Weird choose from list behaviour
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Weird choose from list behaviour


  • Subject: Re: Weird choose from list behaviour
  • From: Brian Christmas <email@hidden>
  • Date: Wed, 14 Nov 2012 09:12:39 +1100


G'day again.

Turned out it was the idiot between the chair and the iMac at fault. Bad, bad scripting. Here's the answer.

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 class of theAnswer is list then
set theAnswer to item 1 of theAnswer
say "here " & theAnswer
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
else
quit me # because it's an application.
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)
else
set thewholelist2 to {}
set end of thewholelist2 to tempReturned --my EnterARecipient(theSecondMenu, theAnswer)
my WriteFile(theFileName, thewholelist2)
if button returned of theAnswer2 = "Back to Main Menu" then
my dataEntry()
else
my Entry1(theFileName, thewholelist2, theAnswer)
end if
end if
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

References: 
 >Weird choose from list behaviour (From: Brian Christmas <email@hidden>)
 >Re: Weird choose from list behaviour (From: "koenig.yvan" <email@hidden>)

  • Prev by Date: Re: Weird choose from list behaviour
  • Next by Date: Table in Word 2012
  • Previous by thread: Re: Weird choose from list behaviour
  • Next by thread: Table in Word 2012
  • Index(es):
    • Date
    • Thread