Re: Find duplicate numbers and replace
Re: Find duplicate numbers and replace
- Subject: Re: Find duplicate numbers and replace
- From: Ed Stockly <email@hidden>
- Date: Thu, 15 May 2008 08:41:43 -0700
My question has created quite a discussion.
Yes, Ruby, that happens sometimes when people are so eager to be
helpful. We could have worse problems.
Even though I am new to Perl and don’t understand the code, Mark’s
solution did work for me, I just copy paste the code into my
script. Now I will read about Perl and maybe even try to understand
the code.
I hear it's useful in some situations.
Ed, I would like to see the applescript version. Because before
posting I tried applescript, nothing worked.
See below. It's set up to run with your text in an open textedit
document, but that can be easily modified and the whole thing could
be optimize, of course.
Watch the line breaks!
HTH
Ed
-------------------
tell application "TextEdit"
set myText to text of document 1 as text
end tell
--set myText to read (choose file)
set AppleScript's text item delimiters to "[F]"
set textList to every text item of myText
copy textList to refList
set foundItems to {}
set AppleScript's text item delimiters to ""
repeat with x from 1 to count of refList
set speedNumber to the last word of item x of refList
set foundCount to 0
repeat with y from (x + 1) to ((count of refList) - 1)
if y is not in foundItems then
set computerNumber to the last word of item y of refList
if computerNumber = speedNumber then
set the end of foundItems to y as integer
set foundCount to foundCount + 1
set appendage to item foundCount of
"abcdefghijklmnopqrstuvwxyz"
set fixLine to item y of textList
set fixLine to fixLine & appendage
set item y of textList to fixLine as text
end if
end if
end repeat
end repeat
set AppleScript's text item delimiters to "[F]"
tell application "TextEdit"
make new document at beginning
set text of document 1 to textList as text
end tell
return textList as string
_______________________________________________
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