Importieren mit change

Beschreibung:

Die Import-Optionen, z.B. welche Textkodierung benutzt werden soll, kann man steuern, wenn man zuerst die Komponente anlegt und dann mit change auf den Inhalt der Importdatei setzt:

set textDatei to choose file with prompt "Text-Datei auswählen"

tell application "RagTime 6.5"
     tell document 1
          set Textkomponente to (make new text flow at end)
          change Textkomponente to textDatei using encoding 256 without link to file
-- Encoding 256 ist Mac Roman
          set Rechenblattkomponente to (make new table at end)
          change cell "A1" of Rechenblattkomponente to textDatei using encoding 256 without link to file, value format detection and import formats
     end tell
end tell

Das Script erzeugt eine neue Textkomponente und setzt dann den Inhalt auf textDatei, gibt aber dabei bereits das Encoding vor. Die für die meisten Anwender wohl wichtigsten Encodings sind:

256: Macintosh Standard für westeuropäische Sprachen
512: Windows Standard für westeuropäische Sprachen

Encoding-Nummern finden Sie in der RagTime-Hilfe "RagTime-Formeln und -Funktionen" im Abschnitt "Hintergrundinformationen".

Es wird ein Rechenblatt angelegt und die Zelle A1 auf die Datei geändert. Da value format detection und import formats beide festgelegt sind (hier: ausgeschaltet), folgt auch dieser Dialog nicht.

Die so importierten Komponenten können mit set (“set rectangle 1 of page 1 to...�) platziert werden.

Für den Import können auch Filter festgelegt werden, besonders bei Bildern bisweilen wichtig:

...convert with "JPEG" ...

Ein Beispielscript:

set bildDatei to choose file with prompt "Bild-Datei auswählen" of type list {"JPEG"}

tell application "RagTime 6.5"
     tell document 1
          set Bildkomponente to (make new picture at end)
          change Bildkomponente to bildDatei ¬
               convert with "JPEG" without link to file
     end tell
end tell