Hello
Step by step, I'm replacing instructions calling ASObjC Runner by handlers from Libraries or directly embedded in the scripts when running under Yosemite.
Here are three handlers. They work but I think that the 3rd one is awful. Alas, I didn't found a command able to do the job without a loop. Maybe somebody will have the missing idea.
use AppleScript version "2.4" use framework "Foundation" use scripting additions
set someText to "azer?tyuio?pqsdfghjk?lmwxcvbn" set mySeparator to "?"
my splitstring:someText withString:mySeparator log result
my searchAndReplace:"azer?tyuio?pqsdfghjk?lmwxcvbn" oldText:"?" newText:"@" log result
my linkStrings:{"azer", "rtyuio", "pqsdf", "ghjklm", "wxcvbn"} withString:" | "
on splitstring:someText withString:mySeparator set theString to current application's NSString's stringWithString:someText --set mySeparator to current application's NSString's stringWithString:mySeparator set theList to theString's componentsSeparatedByString:mySeparator return theList as list end splitstring:withString:
on searchAndReplace:someText oldText:theOldText newText:theNewText set theString to current application's NSString's stringWithString:someText --set theOldText to current application's NSString's stringWithString:theOldText --set theNewText to current application's NSString's stringWithString:theNewText set theString to theString's stringByReplacingOccurrencesOfString:theOldText withString:theNewText return theString as text end searchAndReplace:oldText:newText:
on linkStrings:theList withString:TID # I assume that if the item to append is not already a NSSString, the function # stringByAppendingString will do the conversion. Doing it here does the job only once. set TID to current application's NSString's stringWithString:TID set theString to current application's NSString's stringWithString:"" repeat with i from 1 to count of theList if i < (count theList) then set theString to ((theString's stringByAppendingString:(item i of theList))'s stringByAppendingString:TID) else set theString to (theString's stringByAppendingString:(item i of theList)) end if end repeat return theString as text end linkStrings:withString:
Yvan KOENIG (VALLAURIS, France) mardi 2 juin 2015 21:11:11
|