samedi 17 janvier 2015

Applescript not returning string


I have a list called num. I have converted it into a string. I want to return that string so that the next action called "New text file" in my automator workflow can get the string. This is my code -



on run {input, parameters}
set num to {1,2}
set f to ""
repeat with x in num
set f to f & x & "\n"
end repeat
return f
end run


It doesn't return anything.


EDIT: As some of you have asked. I am going to elaborate on the question. My automator workflow, takes some parts of some text in an email, it retrieves all the phone numbers in the group which is specified in the text of the email, and stores them in a text file.


the variable 'cat' has the list of contact groups


This is the full code:



on run
set cat to value of variable "cat" of front workflow (*I have already defined the variable elsewhere in the workflow*)
set num to {}
set f to ""
tell application "Contacts"
repeat with i in cat
set inGroup to group i
set phoneProps to value of phones of inGroup's people
set end of num to first item of first item of phoneProps
end repeat
end tell
repeat with x in num
set f to f & x & "\n"
end repeat
return f
end run


This code is supposed to be followed by a 'new text file' action which should take the output of the previous action ('run applescript') as input. That doesn't happen as for some reason, applescript refuses to return the value even when I am getting the desired value when using 'display dialog'.





Aucun commentaire:

Enregistrer un commentaire