Bilder laden

Von Jürgen Schell. | 9 April, 2008 - 09:24
Beschreibung:

Im Falle von Bildern braucht man fast immer den Import. Folgender Code lädt eine Datei in ein RagTime-Dokument:

set dasBild to choose file with prompt "Bitte Bild wählen"
tell application "RagTime 6.5"
     tell document 1
          make new picture at end with data dasBild
     end tell
end tell

Das Bild erscheint im Inventar und ist nirgends platziert. Die Komponente hat den Namen der Bilddatei. Folgender Code lädt ein neues Bild in eine bestehende Komponente:

set dasBild to choose file with prompt "Bitte Bild wählen"
tell application "RagTime 6.5"
     tell document 1
          change picture 1 to dasBild
     end tell
end tell

Bei der change-Anweisung kann man auch expizit angeben, ob das Bild mit der Datei verknüpft sein soll oder nicht: “...dasBild with link to file� oder “...dasBild without link to file�. Soll ein Bild mit Verknüpfung geladen werden, benutzt man zuerst make ohne data, dann change:

set Bilddatei to choose file with prompt "Bitte Bild wählen"
tell application "RagTime 6.5"
     tell document 1
          set dasBild to make new picture at end
          change dasBild to Bilddatei with link to file
     end tell
end tell