Errore in applescript "Indice non valido"

0

Ho un flusso di lavoro di un automatore che funziona bene tranne che per una parte di esso - applescript.

Ecco come va il flusso di lavoro -

Esegui applescript (questa parte funziona bene) -

on run {input, parameters}

    tell application "Mail" to set theMessageText to content of (get first message of inbox)
    set x to text ((offset of "9" in theMessageText) + 2) thru ((offset of " " in theMessageText) - 1) of theMessageText
end run

Imposta il valore per la variabile (il nome della variabile è 'numero')

Ottieni valore per variabile (mi sono assicurato che questo non riceva input diretti da azioni precedenti. Sto chiamando la variabile 'numero' qui e ho duplicato questo processo altre 2 volte per chiamare altre 2 variabili)

Esegui Applescript (questo è il codice con cui ho un problema) -

on run {input, parameters}
    set cat to first item of input
    set x to second item of input
    set o to third item of input
    tell application "Contacts"
        set thePerson to make new person with properties {first name:"Testing", last name:"Auto"}
        make new phone at end of phones of thePerson with properties {label:"Main", value:x}
        repeat with z from 1 to o
            set a to item z of cat
            add thePerson to group a
        end repeat
        save
    end tell
end run

L'errore mostrato qui è "Errore di sintassi - Impossibile ottenere l'elemento 2. Indice non valido".

Il punto del flusso di lavoro è ottenere alcuni dettagli di contatto da una e-mail e aggiungerli come contatto nella rubrica (questo non è il flusso di lavoro completo in quanto è abbastanza grande. Ho mostrato solo le azioni pertinenti) .

Sarei grato per qualsiasi aiuto.

    
posta Kevin Vert 20.11.2014 - 20:51
fonte

1 risposta

0

I valori che hai impostato prima non vengono dati tramite il parametro input . Finché esegui Automator Workflow come un flusso di lavoro Automator e non come applicazione o servizio, puoi accedere alle variabili precedentemente impostate utilizzando quanto segue:

tell application "Automator"
    set cat to value of variable "NameOfFirstVariable" of front workflow
    set x to value of variable "NameOfSecondVariable" of front workflow
    set o to value of variable "NameOfThirdVariable" of front workflow
end tell

all'interno dell'azione "Esegui script apice".

Saluti, Michael / Hamburg

    
risposta data 21.11.2014 - 14:38
fonte

Leggi altre domande sui tag