MACSCRPT Archives

November 2006

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Christian Huldt <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Mon, 27 Nov 2006 11:29:41 +0100
Content-Type:
text/plain
Parts/Attachments:
text/plain (35 lines)
On Wed, 22 Nov 2006 13:06:55 -0500, Mark Lively <[log in to unmask]> wrote:
> On Nov 22, 2006, at 12:51 PM, Bob R. wrote:
> 
>> Is there a scripting addition freeware that will sort strings of
>> text in alphabetical order, for
>> OSX?
>>
>> Thanks!
>>
> there is the shell command sort
> 
> set foo to {"a", "b", "d", "g", "aa", "bb", "c", "cc", "e", "f"}
> set AppleScript's text item delimiters to return
> set lun to open for access ("/tmp/junk.txt" as POSIX file) with write
> permission
> write (foo as text) to lun
> close lun
> set outtext to do shell script "sort /tmp/junk.txt"
> every text item of outtext

Wouldn't that be:
--
set foo to {"a", "b", "d", "g", "aa", "bb", "c", "cc", "e", "f"}
set AppleScript's text item delimiters to ASCII character 10
try
	close access ("/tmp/junk.txt" as POSIX file)
end try
set lun to open for access ("/tmp/junk.txt" as POSIX file) with write
permission
write (foo as text) to lun
close lun
set outtext to do shell script "sort /tmp/junk.txt"
set AppleScript's text item delimiters to return
every text item of outtext

ATOM RSS1 RSS2