Saturday, November 18, 2017

#1 2000-05-17 06:00:56 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Arrays

Is there such a thing in apple script as arrays as i want to pass a array to another script and then access each part of the array. Please could anybody let me know if it is posible and how. thank you in advance


One mans trash is another mans treasure

Offline

 

#2 2000-05-17 07:00:35 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Arrays

An array in AppleScript does not relay exist. But you can get a similar effect by using a list of lists. A list of lists is a Primary list which contains other list:

Applescript:

Set a to {{1,2,3},{4,5,6}}
--To reference the second item in second list in the above example you need
Set b to item 2 of (item 2 of a)
--You can walk the list by using a repeat for each nested list:
Repeat with ThisList in a
Repeat with ThisItem in ThisList
log ThisItem
end
end

If your list of lists has more than the above examples then you need to up the 'item of list' to the number of items nested in your array, and in the repeat example the number of repeat's inside the main repeat with each working on the last repeats result.


One mans trash is another mans treasure

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)