• 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: log command
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: log command


  • Subject: Re: log command
  • From: RJay Hansen <email@hidden>
  • Date: Wed, 06 Apr 2016 12:52:24 -0500


On Apr 6, 2016, at 11:35 AM, Steve Mills <email@hidden> wrote:

On Apr 06, 2016, at 11:12 AM, RJay Hansen <email@hidden> wrote:

No answers so let me try asking this:

Am I wrong in thinking if I insert a log command in my script to log a variable’s value, it should be logged every time I run the script?

Yes, every time. Unless your script is skipping sections because possibly you're using a property to control some program flow, and that property is preserved until you recompile the script. Care to show us your script?


Yes, the variables I’m trying to log are being used every time the script runs so they should be logged. Here’s my script (I imagine Nigel Garvey could reduce this to half its size):

--on open theseItems —(this is going to be a droplet when I finish it)

set theseItems to (choose file with prompt "select a pdf to upload" with multiple selections allowed)

tell application "Finder"


--set up paths to the folders
set homePath to (path to home folder) as text
set bluePath to homePath & "Dropbox: Blue"
set conniePath to homePath & "Dropbox: Connie"
set greenPath to homePath & "Dropbox: Green"
set orangePath to homePath & "Dropbox: Orange"
set pinkPath to homePath & "Dropbox: Pink"
end tell

--set up our teams in outlook
tell application "Microsoft Outlook"
--activate
set blueTeam to get members of group "Blue"
set pinkTeam to get members of group "Pink"
set greenTeam to get members of group "Green"
set orangeTeam to get members of group "Orange"
set connieTeam to {{|name|:"Connie Root", address:"email@hidden"}}
end tell

--enter the customer name for the email subject line
tell me to activate
--choose the folder we're going to upload to
set theTeam to choose from list {"Blue", "Connie", "Green", "Orange", "Pink"} with prompt "Choose the team Dropbox folder"

set teamGroup to "" --initialize teamGroup

if item 1 of theTeam is "Blue" then
set thePath to bluePath
set teamGroup to blueTeam
else if item 1 of theTeam is "Connie" then
set thePath to conniePath
set teamGroup to connieTeam
else if item 1 of theTeam is "Green" then
set thePath to greenPath
set teamGroup to greenTeam
else if item 1 of theTeam is "Orange" then
set thePath to orangePath
set teamGroup to orangeTeam
else if item 1 of theTeam is "Pink" then
set thePath to pinkPath
set teamGroup to pinkTeam


log theTeam  —these three variables are being logged the first time I run the script but not on subsequent runs.
log thePath
log teamGroup


end if
set teamCount to count of teamGroup


--now copy the files to the selected dropbox folder
set fileList to {}
set subjectLine to ""
repeat with i from 1 to count of theseItems


tell application "Finder"
set thisItem to item i of theseItems
duplicate file thisItem to thePath
end tell


--grab our file name(s) to put in our email
set fileList to fileList & thisItem
log fileList
set AppleScript's text item delimiters to ":"
set x to item i of fileList
set y to every text item of (x as text)
log y
set fileName to the last text item of y
set item i of fileList to fileName
--grab the customer name to put in subject line
set subjectLine to (text item 4 of y) & " Proof"
set AppleScript's text item delimiters to ""


end repeat
--fileList
delay 3
tell application "Finder"
if exists (thePath as text) & ":" & fileName then
display dialog "File(s) successfully uploaded to Dropbox>"
end if
end tell

--now our email
tell application "Microsoft Outlook"


--compose the message
set a to "The following files are in the "
set b to theTeam
set c to " Dropbox folder: <br>"
set d to ""
repeat with i from 1 to count of fileList
set d to (d & ((item i of fileList as string) & "<br>"))
end repeat
set messageBody to a & b & c & d
log messageBody


--make a new message and add the recipients
set theMessage to make new outgoing message with properties {subject:"THIS IS ONLY A TEST!  " & subjectLine, content:messageBody}


repeat with j from 1 to teamCount
make new recipient at theMessage with properties {email address:{name:(name of item j of teamGroup), address:(address of item j of blueTeam)}, type:to recipient type}
end repeat



--send the message and verify that it has been sent
try
send theMessage
on error errmsg number errnum
display dialog "Email was not sent."
end try


delay 3 --to give outlook time to send the message


try
get was sent of theMessage
on error errmsg number errnum
display dialog "Email was successfully sent."
end try


end tell

--end open
 _______________________________________________
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: log command
      • From: "Stockly, Ed" <email@hidden>
    • Re: log command
      • From: Steve Mills <email@hidden>
References: 
 >Re: log command (From: Steve Mills <email@hidden>)

  • Prev by Date: Re: log command
  • Next by Date: Re: log command
  • Previous by thread: Re: log command
  • Next by thread: Re: log command
  • Index(es):
    • Date
    • Thread