I have a problem with formatting a text file that can be read into an Applescript variable. Below is my script. When I try to sort the file the format is off somehow and it gives an error. If I enter the data locally the script works fine. Quoted out line above the list is reference to the file names.txt of the desktop
Can anyone tell me what's wrong here? I don't want to have to use database events as I am running this script on pre OSX 10.4 machines.
Thanks
-SomeoneElse
set namez to text returned of (display dialog "What's your name?" default answer "names")
-- gets username and uses it as filename
set theFilePath to (path to desktop) & namez & ".txt" as string
set quote to ASCII character of 34
set cr to ASCII character of 13
--set the_data to read file theFilePath
set the_data to {"Mike", "Rita", "frank", "fred", "frodo", "fritz", "Ed", "Dave"}
set the_list to the_data
repeat (length of the_list) times
repeat with j from 1 to (length of the_list) - 1
if item j of the_list > item (j + 1) of the_list then
set {item j of the_list, item (j + 1) of the_list} to {item (j + 1) of the_list, item j of the_list}
end if
end repeat
end repeat
the_list
Can anyone tell me what's wrong here? I don't want to have to use database events as I am running this script on pre OSX 10.4 machines.
Thanks
-SomeoneElse
set namez to text returned of (display dialog "What's your name?" default answer "names")
-- gets username and uses it as filename
set theFilePath to (path to desktop) & namez & ".txt" as string
set quote to ASCII character of 34
set cr to ASCII character of 13
--set the_data to read file theFilePath
set the_data to {"Mike", "Rita", "frank", "fred", "frodo", "fritz", "Ed", "Dave"}
set the_list to the_data
repeat (length of the_list) times
repeat with j from 1 to (length of the_list) - 1
if item j of the_list > item (j + 1) of the_list then
set {item j of the_list, item (j + 1) of the_list} to {item (j + 1) of the_list, item j of the_list}
end if
end repeat
end repeat
the_list