Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Corrado33

macrumors member
Original poster
Sep 2, 2008
62
0
So I'm writing a program that periodically adds things to a list. That's the easy part. However, each item in the list has it's own separate list associated with it. So let's say my script adds something to the first list, that would mean it would need to create the corresponding list that goes along with that entry, but I don't know how to make applescript make it's own variables. I'll make a diagram to try to explain this.

Initial List. . . .Sub_lists
. . .|. .. . . . .Entry1-1
. . \|/ . . . . Entry1-2
Entry1--------Entry1-3

. . . . . . Entry2-1
Entry2-- Entry2-2
. . . . . . Entry2-3

Entry3---Entry3-1
. . . . . .\Entry3-2
. . . . . . Entry3-3

So if I make Entry4, I would need the program to make the sublist that includes Entry4-1, Entry4-2, and Entry4-3.
Then, if I make Entry5, again I would need the corresponding sublist, but with a different name (so I can save all of the sublists separately)

Hmm, I just thought maybe I could use files, and output the stored lists into a text file.... I'll try that too.

Anybody have a way I could just make variables like I was saying? Thanks!
 
Honestly, I'm a little vague on what you're trying to do, but maybe this will help.

Code:
set masterList to {}

set dummyList to {1, 2, 3}

set masterList to masterList & dummyList

set dummyList to {4, 5, 6}

set masterList to masterList & dummyList

set dummyList to {7, 8, 9}

set masterList to masterList & dummyList

masterList is {1, 2, 3, 4, 5, 6, 7, 8, 9}

Code:
set masterList to {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

set dummyList to {1, 2, 3}

set item 1 of masterList to dummyList

set dummyList to {4, 5, 6}

set item 2 of masterList to dummyList

set dummyList to {7, 8, 9}

set item 3 of masterList to dummyList

masterList is {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, 0, 0, 0, 0, 0, 0, 0}

Does this help?

mt
 
Alternatively, you should have an application called "Database Events" on your Mac. (Check /System/Library/CoreServices) It is a scriptable, faceless app, where you can create fields, and create and delete records. Here's an intro.

You should see a speed advantage with Database Events over reading/writing to a text file.

mt
 
Both of you are ingenious. :) Thank you so much, that's exactly what I need to do.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.