Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Enthusiast Zone > Classic Macs and Mac OS > Apple Script replace

Apple Script replace
Thread Tools
Addicted to MacNN
Join Date: Sep 2000
Status: Offline
Reply With Quote
Aug 3, 2001, 09:20 AM
 
I got a quck AppleScript question for anyone with an aswer

I have a script in which the variable may contain a space " " such as "dog and cat"

How would I go about having the script read the data and replace it with another character(s) such as "dog$and$cat"?


Anyone know?
I always use protection when fscking my Mac... Do you?
     
Junior Member
Join Date: May 2001
Status: Offline
Reply With Quote
Aug 3, 2001, 09:55 AM
 
probably the easiest way would be to use delimiters to mark the space characters & replace them with "$" characters...
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>set thedata to <font color = red>"dog and cat"</font>
set the text item delimiters to <font color = red>" "</font>
set datalist to text items of thedata as list
set the text item delimiters to <font color = red>"$"</font>
set thenewdata to datalist as string
-- <font color = red>"dog$and$cat"</font>
set the text item delimiters to <font color = red>""</font></font>[/code]
this would just create a list of the individual characters in the string & replace all the " "'s with "$"'s, then convert the list back to a string (thenewdata).
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -4. The time now is 01:31 AM.
All contents of these forums © 1995-2014 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2014, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2