• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
from ASObjC Runner to Yosemite
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

from ASObjC Runner to Yosemite


  • Subject: from ASObjC Runner to Yosemite
  • From: Yvan KOENIG <email@hidden>
  • Date: Tue, 02 Jun 2015 21:11:21 +0200

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


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: from ASObjC Runner to Yosemite
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Re: Setting up Distributable Script App to Delete a File in /Library/Application Support
  • Next by Date: Re: from ASObjC Runner to Yosemite
  • Previous by thread: Re: Setting up Distributable Script App to Delete a File in /Library/Application Support
  • Next by thread: Re: from ASObjC Runner to Yosemite
  • Index(es):
    • Date
    • Thread