set t to "a,b,c
d,e,f
g,h,i"
set s to return
set r to "x"
set change_t to replaceText(s, r, t)
display dialog change_t
on replaceText(find, replace, subject)
set prevTIDs to text item delimiters of AppleScript
set text item delimiters of AppleScript to find
set subject to text items of subject
set text item delimiters of AppleScript to replace
set subject to "" & subject
set text item delimiters of AppleScript to prevTIDs
return subject
end replaceText
Feel free to use this search and replace handler I've used for years:
-- begin script
-- usage example:
set theFile to choose file with prompt "Choose any text file:"
set theString to read file theFile
return SearchReplace(theString, ".", "<PERIOD>")
on SearchReplace(sourceStr, searchString, replaceString)
-- replace <searchString> with <replaceString> in <sourceStr>
set searchStr to (searchString as text)
set replaceStr to (replaceString as text)
set sourceStr to (sourceStr as text)
set saveDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to (searchString)
set theList to (every text item of sourceStr)
set AppleScript's text item delimiters to (replaceString)
set theString to theList as string
set AppleScript's text item delimiters to saveDelims
return theString
end SearchReplace
-- end script
--
Send responses to the relevant news group rather than email to me.
E-mail sent to this address may be devoured by my very hungry SPAM
filter. Due to Google's refusal to prevent spammers from posting
messages through their servers, I often ignore posts from Google
Groups. Use a real news client if you want me to see your posts.
JR
> In article
> <dcdef6e4-468e-4523...@x14g2000yqk.googlegroups.com>,
> Don't use "\r". Use "return" without the quotes.
Exactly.
The AppleScript keyword "return" (without quotes) is the same as:
ascii character 13
If you wanted or needed to, you could set a variable to it like this:
set cr to ascii character 13
-or-
set cr to return
> In article <jollyroger-5204E...@news.individual.net>,
> Jolly Roger <jolly...@pobox.com> wrote:
>
> > In article <061220081429101031%dave@N_O_T_T_H_I_Sbalderstone.ca>,
> > Dave Balderstone <dave@N_O_T_T_H_I_Sbalderstone.ca> wrote:
> >
> > > In article
> > > <dcdef6e4-468e-4523...@x14g2000yqk.googlegroups.com>,
> > > Mosby <dril...@aol.com> wrote:
> > >
> > > > I still have the same problem. I want to replace carriage returns
> > > > with "" (null) but I cannot get it to do the replacement. It works
> > > > fine the way you have it set up, but when I change the search string
> > > > to "\r" and the replacement string to "" it does not perform the
> > > > replacement. However, I found that it did work using and other
> > > > replacement string besides "" (null). Why would that be? Thanks for
> > > > the help, BTW.
> > >
> > > Don't use "\r". Use "return" without the quotes.
> >
> > Exactly.
> >
> > The AppleScript keyword "return" (without quotes) is the same as:
> >
> > ascii character 13
> >
> > If you wanted or needed to, you could set a variable to it like this:
> >
> > set cr to ascii character 13
> > -or-
> > set cr to return
>
> You can actually set "return" to anything you want.
>
> set return to "anything you want"
> return
>
> -->"anything you want"
Wow neat. Never thought to try that. : )
Here is a sample data file:
"B0""Williams""George""W""477044773""S""9136544031""George W.
Williams""666 Dover Lane""Gunnison ""TX""67020""301""14772"""""
"C0""6910A""Anderson""James""R""M""0839269""N""""N"
"D0""01""6910A""F""CB900""Red Cross/ Oran
""NOCD""467689234""0777771""900/400""Anderson""James""R""77771969""GW""Y""N""01""""X"
"D1""01""6910A""726 E. Acheson""S""Corpus""TX""99999"""""
"E5""6910A"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"E6""6910A""""455555773""Wilson""Jack""W""301"""""""""""""
"F5""01""6910A""""29""""188338""09990""8100"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"X0""6910A"""""""
"Y0"
Maybe I'm going about this all wrong. The data is enclosed in quotes
with a return at the end of the line. I don't need the return or the
quotes. I would like to have a long list of items. I am going to use
that list to verify the data in the file. When I generate my list of
items I end up with an item that has a (quote,return,quote,C0). This
is the end of the first line. I will try to show the item below....
"
"C0
If I could get rid of the returns I would be done. Is there another
method to generate my list of data?