(1) In my sample script I used two syntaxes.# 1st way set aList to myLib's decoupe(theString, "vos") log aList
# 2nd way tell myLib set theString to recolle(aList, "NOS") end tell
The first one is OK when we use a single instruction calling the library. The second is better when we use several calls to handlers of the library.
use myLib : script "fakeLib" use scripting additions
set the_String to "Pour qui sont ces serpents qui sifflent sur vos têtes" copy the_String to theString1 tell myLib set theString1 to remplace(theString1, "serpents", "forts vents") set theString1 to remplace(theString1, "sifflent", "soufflents") set theString1 to remplace(theString1, "vos", "nos") end tell
copy the_String to theString2 repeat with aCouple in {{"serpents", "forts vents"}, {"sifflent", "soufflent"}, {"vos", "nos"}} set theString2 to myLib's remplace(theString2, aCouple's item 1, aCouple's item 2) end repeat {theString1, theString2}
(2) Before posting I carefully checked if my memory was right. To do that I tried to use:
use script "fakeLib" use scripting additions
set theString to "Pour qui sont ces serpents qui sifflent sur vos têtes"
set aList to its decoupe(theString, "vos") log aList
set theString to recolle(aList, "NOS")
It's simpler … but it fails issuing the message : error "«script» ne comprend pas le message « decoupe »." number -1708 from «script»
Yvan KOENIG running Sierra 10.12.4 in French (VALLAURIS, France) dimanche 30 avril 2017 11:05:13
|