MacNN Forums (http://forums.macnn.com/)
-   Classic Macs and Mac OS (http://forums.macnn.com/classic-macs-and-mac-os/)
-   -   Apple Script replace (http://forums.macnn.com/64/classic-macs-and-mac-os/47751/apple-script-replace/)

 
macvillage.net Aug 3, 2001 09:20 AM
Apple Script replace
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?
 
acur128 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).
 
All times are GMT -4. The time now is 07:23 AM.

Copyright © 2005-2007 MacNN. All rights reserved.
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2014, vBulletin Solutions, Inc.


Content Relevant URLs by vBSEO 3.3.2