Monday, July 28, 2014

#1 2012-12-14 12:31:08 pm

pjdube
Member
Registered: 2012-10-13
Posts: 77

A little help with my Automator action.

For some reason the below applescript works well all by itself in AppleScript Editor, yet when I try to run it in Automator an error comes up which says the following:

Syntax Error

Expected "given","with","without", other parameter
name, etc. but found identifier.

It highlights theTitle in the below applescript.

Applescript:


on run
   set {dChange, chAnge, Csum, oName, oPost, sName, sPost} to (inputItems for {"• Date of Change", "• Summary", "• Change", "• Who created the change (name)", "• Who created the change (post)", "• Person Logging (name)", "• Person Logging (post)"} with title given prompt:"Enter the following items separated by a carriage return:")
end run

to inputItems for someItems given title:theTitle, prompt:thePrompt
   if thePrompt is in {true, false} then -- "with" or "without" prompt
       if thePrompt then
           set thePrompt to "Input the following items:" & return & return & return & return & return & return & return -- default
       else
           set thePrompt to ""
       end if
   else -- fix up the prompt a bit
       set thePrompt to thePrompt & return & return & return & return & return & return & return
   end if
   
   if theTitle is in {true, false} then if theTitle then -- "with" or "without" title
       set theTitle to "Changes Log Input" -- default
   else
       set theTitle to ""
   end if
   
   if class of someItems is integer then -- no item list
       set {theCount, someItems} to {someItems, ""}
       if thePrompt is not "" then set thePrompt to text 1 thru -2 of thePrompt
   else
       set theCount to (count someItems)
   end if
   if theCount is less than 1 then error "Input Changes Error: Empty input list."
   set {theItems, theInput} to {{}, {}}
   
   repeat theCount times -- set the number of lines in the input
       set the end of theInput to ""
   end repeat
   set {tempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
   set {someItems, theInput} to {someItems as text, theInput as text}
   set AppleScript's text item delimiters to ","
   
   set theInput to paragraphs of text returned of (display dialog thePrompt & someItems with title theTitle default answer theInput)
   
   repeat with anItem from 1 to theCount -- pad/truncate entered items
       try
           set the end of theItems to (item anItem of theInput)
       on error
           set the end of theItems to ","
       end try
   end repeat
   return theItems as string
end inputItems

Can anyone figure out what I am doing wrong here?

Thanks.

Phil


Filed under: , applescript, Automator

Offline

 

#2 2012-12-14 02:22:40 pm

mark hunte
Member
From: Hello, London Calling
Registered: 2006-03-20
Posts: 1012
Website

Re: A little help with my Automator action.

change it to :

Applescript:

tell application "System Events"
       set theInput to paragraphs of text returned of (display dialog thePrompt & someItems with title theTitle default answer theInput)
   end tell

When I took out the Title property from the dialog. I got a single text line and prompt that did not look correct.
this tells me Automator does not understand the dialogue code as you would expect it to.

So I put it in something I know should understand it as I expect.

Last edited by mark hunte (2012-12-14 02:27:29 pm)


Tap,tap,tap , hello , testing 1..2,  1...2,
http://www.markosx.com/thecocoaquest/

Offline

 

#3 2012-12-14 02:39:03 pm

pjdube
Member
Registered: 2012-10-13
Posts: 77

Re: A little help with my Automator action.

Mark, Thanks a lot. That worked perfectly.

Regards,

Phil

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.070 seconds, 11 queries executed ]

RSS (new topics) RSS (active topics)