RE: merge same (beginning) filenames into different variables
RE: merge same (beginning) filenames into different variables
- Subject: RE: merge same (beginning) filenames into different variables
- From: has <email@hidden>
- Date: Thu, 19 May 2005 15:01:27 +0100
Jan-Bultereys wrote:
>The purpose is to generated different variables just with a list of filenames....
>The names of the files really does not matter BUT if they have the same beginning
>they have to be declared to a variable...
First thing is that you can't define new AppleScript variables on-the-fly, and in any case it'd be completely the wrong way to do it. Either:
1. Store each list of filenames in an ordered list, e.g.
{{"test10page100", "test10page200"}, {"testApage200"}, ...}
This'll allow you to retrieve each group by index.
Or:
2. Store each list of filenames in a dictionary object. (As my previous example demonstrated.) This'll allow you to retrieve each group by name.
Without knowing how you're going to consume this data at the end of the day I don't know which is more appropriate to your needs. Basically, decide how the rest of your program need to retrieve these values, either using numeric indexes or named keys, and use the appropriate solution.
>example:
>test10page100
>test10page200
>should be going in the Variable: VAR1..... etc....
>testApage200
>should be going in the Variable VAR2 .... etc
>testBApage150
>testBApage266
>should be going in the Variable VAR3 ... etc
Second thing is you need to figure out how you're going to extract a 'key' from each filename. In your above examples, the key part seems to be everything before the word 'page', in which case you could just use TIDs to get it:
on extractKey(theValue)
set text item delimiters to "page"
return theValue's text item 1
end extractKey
Though if that assumption's wrong then you'll need to provide more information on the different sorts of filenames involved and what exactly constitutes the key part versus the non-key part.
>I know it's pretty hard to explain....
Nah, explaining's easy when you know what it is you want. Hardest part of programming is figuring out what it is you actually need in the first place. A good start is to get yourself paper and pencil and write down all the requirements you know of in _plain English_. Don't even start thinking about how you're going to write the actual code until you've got your written requirements ironed out first. Write down WHAT you want to do, rather than HOW. (e.g. What the program will do, what goes in, what comes out, what each of the major steps involved in processing the data needs to do, etc.) Provide as much "big picture" information as you can and don't worry about the minor details. Start rough, and gradually edit and revise these notes as individual points become clearer. Takes practice, but it's worth it.
HTH
has
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden