Home of |
|
austauschen |
|
"Austauschen" ist eine ultraschnelle AppleScript-Routine, mit der Suchen/Ersetzen-Vorgänge in Strings ca. 300 mal schneller ablaufen als mit den üblichen Routinen. (Die üblichen Routinen gehen mit einer Schleife durch den String.) "Austauschen" wurde von mir, Sascha Welter, erfunden und allen AppleScriptern kostenlos und frei zur Verfügung gestellt. Alles, was ich mir wünsche, ist dass ich als Autor der Routine zitiert werde. Aber Achtung: Austauschen funktioniert erst ab OS 8, bei Systemen vor OS8 könnte es Ihren Mac hängen oder abstürzen lassen. Wenn Sie Scripts schreiben, die Sie weitergeben möchten, sollten sie mit einer Routine die Systemversion überprüfen. |
|
"Austauschen" is an ultrafast AppleScript-Routine, which makes search/replace-Operations about 300 times faster than the usual routines. (The usual Routines would loup through the string.) "Austauschen" was invented by me, Sascha Welter, and I offered it without cost and free to all AppleScripters. All I ever asked for was that I would be quoted as the author. But take care: Austauschen works only on OS 8 and later, on systems before OS8 it could hang or crash your mac. If you write scripts to give to other people include a routine that checks for the system version. |
Geschichte:Ungefähr am Anfang Dezember 1997 zerbrach ich mir den Kopf weil ich etwas brauchte, um in einem String einen Text zu suchen/ersetzen. Dieses etwas müsste funktionieren, ohne etwas im Systemordner zu installieren -- weil es gedacht war um auch auf anderer Leute rechner zu laufen.Eines Nachts arbeitete ich spät und endlich begann ich ausserhalb der Grenzen zu denken. Das Resultat ist "austauschen". Einige Wochen später schrieb ich einige scripts für die Emailer-Talk mailingliste und als ich sie auf meiner Webseite publizierte, schrieb ich dieses Mail auf der Liste: |
|
History:About in the beginning of december 1997 I was banging my head on the wall, because I needed something to search/replace in a string. This thing would have to run without installing something in the system folder -- because it was meant to run on other peoples machines.One night I was staying up late and finally I began to "think outside the dots". The result is "austauschen" (austauschen is the german word for "swap"). A couple of weeks later I had written some scripts for the Emailer-Talk mailinglist and when I published them on my webpage I announced them on the list: |
Thema: [Announce] Saschas EmailerScripts on the Web Datum: 24.12.1997 16:55 Uhr An: Emailer-Talk, emailer-talk@eskimo.com Hi! I managed to put some of the AppleScripts I have done for Claris Emailer on my home page. These Scripts include the "Dated messages" scripts, ready to use for US and European style dates (thank you Brian for testing this out!) The scripts come all in one package (121k stuffed and binhexed): * Stupefy Quotes, ..., etc. Turn curly quotes, ellipsis, ligatures etc. into their ASCII counterparts This Script uses a search/replace subroutine I brewed up myself and which is approx. 300 times faster than the average "loop through a string AppleScript search/replace" -- without needing any osaxen. Could be of interest to you scripters out there. ... |
||
Wie funktioniert es?Der Lattenzaun
Es war einmal ein Lattenzaun,
mit Zwischenraum, hindurchzuschaun.
Ein Architekt, der dieses sah,
stand eines Abends plötzlich da --
und nahm den Zwischenraum heraus
und baute draus ein grosses Haus.
Der Zaun indessen stand ganz dumm
mit Latten ohne was herum.
Ein Anblick grässlich und gemein,
drum zog ihn der Senat auch ein.
Der Architekt jedoch entfloh
nach Afri- od. Ameriko.
Christian Morgenstern
|
|
How does it work?The Picket Fence
One time there was a picket fence
with space to gaze from hence to thence
An architect who saw this sight
approached it suddenly one night.
Removed the spaces from the fence
and built of them a residence.
The picket fence stodd there dumbfounded
with picket wholly unsurrounded,
a view so loathsome and obscene,
the Senate had to intervene.
The architect, hoowever, flew
to Afri- or Americoo.
Christian Morgenstern
(Translation by Max Knight)
|
Und dies ist austauschen: |
|
And this is austauschen: |
|
(* Saschas fast search/replace routine for AppleScript searching and replacing in a string.
This routine is my very own invention. So if you use it in your own scripts (that's OK with me!), then I want you to credit me within the source of your AppleScript and within any Readme-Files and Documentation your AppleScripts may have. (Just keep this comment in your script.)
This routine is approx. > 300 times faster than searching replacing by looping through
on austauschen(suchen, ersetzen, theString) -- Parameters: search, replace, the String
|
||
"austauschen" Schritt für Schritton austauschen(suchen, ersetzen, theString) -- Parameters: search, replace, the StringDie erste Zeile der Routine gibt an, welche Parameter gebraucht werden, umd die Routine aufzurufen: Es ist der zu suchende String (suchen), der String, der dafür eingesetzt werden soll (ersetzen) und zuletzt, der String indem die Suchoperation aufgeführt werden soll (theString).
set my text item delimiters to (suchen)
set my text item delimiters to (suchen)
tell me to set theList to (every text item of theString)
set my text item delimiters to (ersetzen)
set theString to theList as string
set my text item delimiters to olddelis
|
|
"austauschen" step by stepon austauschen(suchen, ersetzen, theString) -- Parameters: search, replace, the StringThe first line in our subroutine declares the needed parameters, to call the routine: It's the String that we want to search for (called "suchen"), the string that we want to replace it with (called "ersetzen") and last the string where the search operation should take place (called "theString").
set my text item delimiters to (suchen)
set my text item delimiters to (suchen)
tell me to set theList to (every text item of theString)
set my text item delimiters to (ersetzen)
set theString to theList as string
set my text item delimiters to olddelis
|
Fragen, Antworten und Lobeshymnen:Sie können Ihre Fragen, Antworten und Lobeshymnen an den Autor schicken: Sascha Welter, swelter@mus.ch. |
|
Questions, Answers and Praise:You may send your questions, Answers ans Praise to the Author: Sascha Welter, swelter@mus.ch. |
Back home (english) - Zurück zur homepage (deutsch)
Back to my AppleScript-page - Zurück zu meiner AppleScript-Seite