Re: Counting Identical lines in a file with BBEdit & Grep
Re: Counting Identical lines in a file with BBEdit & Grep
- Subject: Re: Counting Identical lines in a file with BBEdit & Grep
- From: kai <email@hidden>
- Date: Mon, 28 Jul 2003 20:23:01 +0100
on Mon, 28 Jul 2003 10:13:55 +0100, I wrote:
>
==========================
>
>
to countIdenticalLines from l
>
set c to {}
>
set d to ASCII character 1
>
set text item delimiters to return
>
set l to l's text items 1 thru -2
>
set text item delimiters to d & d
>
set l to d & l & d
>
repeat until (count l) is 0
>
set text item delimiters to d
>
set w to l's text item 2
>
set text item delimiters to d & w & d
>
set l to l's text items
>
set c's end to ((count l) - 1 as string) & ": " & w
>
set text item delimiters to ""
>
set l to l as string
>
end repeat
>
set text item delimiters to return
>
set c to (c as string) & return
>
set text item delimiters to {""}
>
c
>
end countIdenticalLines
>
>
==========================
Just a couple of additional points on whether or not the final lines
(should) end with a return character.
Firstly, line 4 of the handler <set l to l's text items 1 thru -2> should
work just as well without the '1 thru -2' ending. (That way, it doesn't
matter if the final line of the original text includes a return character or
not.)
Also, the ' & return' ending of the handler's 17th line <set c to (c as
string) & return> is obviously optional.
---
kai
_______________________________________________
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.