Applescript che non restituisce una stringa

0

Ho una lista chiamata num. L'ho convertito in una stringa. Voglio restituire quella stringa in modo che la prossima azione chiamata "Nuovo file di testo" nel flusso di lavoro del mio automatore possa ottenere la stringa. Questo è il mio codice -

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

Non restituisce nulla.

EDIT: come alcuni di voi hanno chiesto. Ho intenzione di approfondire la domanda. Il mio flusso di lavoro dell'automatore, prende alcune parti di un testo in un'email, recupera tutti i numeri di telefono nel gruppo specificato nel testo dell'email e li archivia in un file di testo.

la variabile 'cat' ha l'elenco dei gruppi di contatto

Questo è il codice completo:

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

Questo codice dovrebbe essere seguito da un'azione "nuovo file di testo" che dovrebbe prendere come input l'output dell'azione precedente ("run applescript"). Ciò non accade perché, per qualche ragione, applecript si rifiuta di restituire il valore anche quando ottengo il valore desiderato quando uso 'display dialog'.

AGGIORNAMENTO: sto pubblicando l'intero flusso di lavoro

INPUT- Nell'app di posta - Un'email con questo contenuto: "#a, #b Q: questa è una domanda per tutti voi".

Flusso di lavoro -

1) Esegui Applescript Codice -

 on run {input, parameters}

    tell application "Mail" to set theMessageText to content of (get first message of inbox)
    set topic to text ((offset of "#" in theMessageText) + 1) thru ((offset of "Q" in theMessageText) - 1) of theMessageText
    set AppleScript's text item delimiters to ", "
    set bowords to words of topic
    set o to length of bowords
    repeat with i from 1 to o
        trim_line(bowords, "#", 0)
    end repeat
    bowords
end run
on trim_line(this_text, trim_chars, trim_indicator)
    set x to the length of the trim_chars
    -- TRIM BEGINNING
    if the trim_indicator is in {0, 2} then
        repeat while this_text begins with the trim_chars
            try
                set this_text to characters (x + 1) thru -1 of this_text as string
        on error
                -- the text contains nothing but the trim characters
                return ""
            end try
        end repeat
    end if
    -- TRIM ENDING
    if the trim_indicator is in {1, 2} then
        repeat while this_text ends with the trim_chars
            try
                set this_text to characters 1 thru -(x + 1) of this_text as string
            on error
                -- the text contains nothing but the trim characters
                return ""
            end try
        end repeat
    end if
    return this_text
end trim_line

2) Imposta il valore della variabile

Imposta l'output dell'azione precedente su "cat"

3) Esegui Applescript

on run {input, parameters}
    tell application "Mail" to set theMessageText to content of (get first message of inbox)
end run

4) Nuovo messaggio di posta

Aggiunge il testo dell'azione precedente al corpo dell'email

5) Esegui Applescript

Il codice che @Tetsujin ha dato nelle risposte

6) Nuovo file di testo

7) Aggiungi allegati al messaggio anteriore

8) Invia messaggi in uscita

9) Esegui Applescript (elimina l'e-mail)

Codice -

on run {input, parameters}
    delay (10)
    tell application "Mail"
        set theMessages to (get selection)
        repeat with eachMessage in theMessages
            set theAccount to account of (mailbox of eachMessage)
            move eachMessage to mailbox "Trash" of theAccount
        end repeat
    end tell    
    return input
end run
    
posta Kevin Vert 16.01.2015 - 20:39
fonte

1 risposta

1
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 myString to ""
    tell application "Contacts"
        repeat with i in cat
            set inGroup to group i
            set phoneProps to value of phones of inGroup's people
            repeat with i in phoneProps
                try
                    set myString to myString & "\n" & first item of i (*gets first number only*)
                on error
                    set myString to myString & "\n" & "blank field" (*covers for empty phone number, otherwise would halt on error*)
                end try
            end repeat
        end repeat
        return myString
    end tell  
end run
    
risposta data 17.01.2015 - 16:17
fonte

Leggi altre domande sui tag