Re: BEST way to change 1 character in a file?
Re: BEST way to change 1 character in a file?
- Subject: Re: BEST way to change 1 character in a file?
- From: "fredo.mkb" <email@hidden>
- Date: Thu, 13 Feb 2003 10:37:35 +0100
>
Hi, List.
>
>
I am picking up some text and saving to a file, using URL Access Scripting.
>
When I save the file, I am discovering that the carriage returns are PC
>
returns (ascii character 10).
>
If I save the text using Internet Explorer, I get MAC returns (ascii character
>
13), which is what I want.
>
My first thought was to use a linear (character-by-character search) to find &
>
replace them, but there's a better way, I'm sure.
>
>
What is the fastest AppleScript way to make these PC carriage returns (in a
>
.txt file) become MAC returns (ascii character 13)?
>
>
Anyone have a fancy one-liner I could use for this?
>
>
Thanks in advance.
>
>
-Chris Nitz
Hi :)
I think you can use the "text items delimiters" of AppleScript,
here one solution :
[Script Search/Replace 1 Character in File]
--Variables
set RetPc to (ASCII character 10)
set RetMac to (ASCII character 13)
--Choose file and read contents
set Doc to (choose file)
set Txt to read Doc
--Search and replace characters
set text item delimiters of AppleScript to RetPc
set Lst to text items of Txt
set text item delimiters of AppleScript to RetMac
set TxtOk to Lst as text
set text item delimiters of AppleScript to ""
--Write new text in same file
set eof of Doc to 0
write TxtOk to Doc
[/Script]
--
Fredo d;o)
http://perso.magic.fr/fredomkb/
"One step at time is enough for me..." (Gandhi)
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.