2016-10-06 7 views
1

Ich versuche ein AppleScript zu erstellen, das ein Dokument öffnet und alles, was ich in das Textfeld eintippe, zum Dokument hinzufügt und dann in einem Pfad speichert. Wenn ich versuche, es zu speichern, sagt es nur "konnte x nicht speichern, weil die Datei nicht existiert."Erstellen eines AppleScript-Adressbuchs

Hier ist mein Code

display dialog "username" default answer "" 
 
set the target_username to the text returned of the result 
 
display dialog "password" default answer "" with hidden answer 
 
set the pass to the text returned of the result 
 
if target_username is "Plasma" and pass is "Sship" then 
 
    display dialog "Welcome! Please select a function!" buttons {"Add address", "View address"} 
 
    if button returned of result is "Add address" then 
 
     set booka to text returned of (display dialog "rers!" default answer "") 
 
     tell application "TextEdit" 
 
      activate 
 
      make new document 
 
      set text of document 1 to booka 
 

 
      delay 10 
 
      set thePath to "/Users/Cameron/Desktop/" 
 
      set thedoc to document 1 
 
      set thetitle to "food" 
 
      save thedoc in (thePath & thetitle) 
 
     end tell 
 
    else 
 
     display dialog "no" 
 
    end if 
 
else 
 
    display dialog "no" 
 
end if 
 
}

Antwort

0

Das Skript bellow kann in txt-Datei speichern.

set booka to "my string" -- set booka variable just for testing ! 
tell application "TextEdit" 
activate 
make new document 
set text of document 1 to booka 
set thePath to "Users:Cameron:Desktop:food.txt" 
tell document 1 to save in file thePath 
end tell 
+0

es immer noch nicht funktioniert, es gibt mir den gleichen Fehler – PLASMAGHOST

+0

Script arbeitet für mich, natürlich ‚Cameron‘ von durch eigenen Benutzernamen ersetzen. Sind Sie sicher, dass Ihr Benutzer "Cameron" ist? (das ist das einzige, was ich nicht testen kann) – pbell

+0

ok es hat funktioniert, danke! – PLASMAGHOST