List sorting dilemma
List sorting dilemma
- Subject: List sorting dilemma
- From: Rips Ethan J <email@hidden>
- Date: Thu, 25 Jul 2002 09:39:33 -0400
Hello, all-
I'm writing a script that lists the (graphics) files in a folder on our
Win2000 server, sorts them in numerical order & inserts each into a new
Quark document. (I've reverted to OS 9.2.2 on a G4/800 for this project due
to OS X 10.1.5's access restrictions on our Win2000 server.)
I'm able to access the list of files, but in attempting to use a quicksort
implementation (posted a while back by Arthur Knapp-not that he's
responsible for any of my -er- results), the quicksort handler gets a stack
error.
Here's what I've got:
--First, I assign the path to the folder to var imagepath:
set imagePath to alias "Production:Fact Sheets:= 2002:06_02 Fact Sheets:Pie
Charts:" as string
--Then the list of items in that folder to var imageList:
set imageList to every item of alias imagePath
--(I do the same for a list of documents in another folder, but that's for
later.)--this is the vanilla quicksort:to quicksort(Lst, A, Z) copy {A, Z,
Lst's item ((A + Z) div 2)} to {l, R, val} repeat until R * l
repeat while Lst's item l < val copy l + 1 to l end
repeat repeat while Lst's item R > val copy R - 1
to R end repeat if l * R then copy {Lst's item l,
Lst's item R, l + 1, R - 1} to {Lst's item R, Lst's item l, l, R} end
repeat if A < R then quicksort(Lst, A, R) if Z > l then quicksort(Lst,
l, Z) Lstend quicksort--I pass the list of graphics files as the first
parameter when I call
--quicksort below-unless what I'm passing isn't what I think it
is...quicksort(imageList, 1, imageList's length) --stack overflow
imageList contains 15 items, each of which has the following format:
file "699PER-0602pieCht.tif" of folder "Pie Charts" of folder "06_02 Fact
Sheets" of folder "= 2002" of folder "Fact Sheets" of disk "Production"
Is there a way to reference a file such that the returned values take the
form folder:folder:folder:file? I wonder if that might affect the results
I'm getting...imageList --the script never gets this far.
The rest of the script involves importing a tiff into a Quark picture box,
centering it, saving the document & closing it-not terribly arcane.
I also need to figure out how to access the names of the graphics files so I
can concatenate them to imagePath to insert the graphics programmatically,
like so:
set image i to alias (imagePath & nameOfImage_i)
I really need to figure out the stuff above because if I can't, I'll have to
hard code the file names & paths & that's ridiculous (especially given that
there are several users who will be using this script).
Any help will be greatly appreciated.
Thanks!
Ethan
Lost (as usual) in a forest of file & folder references.... <sigh>
*****************************************************************
DISCLAIMER: The information contained in this e-mail may be confidential
and is intended solely for the use of the named addressee. Access, copying
or re-use of the e-mail or any information contained therein by any other
person is not authorized. If you are not the intended recipient please
notify us immediately by returning the e-mail to the originator.
_______________________________________________
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.