Pathnames in AppleScript

I need to check the existance of a folder (among other things) in a script I’m writing, and I was wondering if there is an alternative to specifying the entire path to folder. A lot of languages, if you refer to a file/folder, its usually relative to the folder the app/script is running from…does AppleScript not do it this way?

Also, I need to use a 2 dimensional array in the script I’m writing, but I’ve only gotten it to work by predefining how many lists are within the list (i.e. set db to {{},{},{},etc…}). Is there a way to easily add another list? I’ve tried:

set db to {1,2,3}
set db to {db,{4,5,6}}
set db to {db,{7,8,9}}

But, when I do it this way, the brakets get all weird - {{{1,2,3},{4,5,6}},{7,8,9}} - or something like that, which screws it all up.

Thanks.

To check for the existence of an item that is located in the same folder as the script or application looking for it try:

tell application "Finder" to set myPath to folder of (path to me) as string

I’m a little foggy on your bracket problem. Are you looking to build a list of 3 sublists?

Try:

set moo to {}

copy {1, 2, 3} to the end of moo
copy {4, 5, 6} to the end of moo
copy {7, 8, 9} to the end of moo

Sweetness! That fixes both my problems. Thank you :D.

Another question, how do property variables work? As I understand it, property variables values are saved after a script runs…is this right?

Also, how would I go about reading/writing that 2-dimensional array to a file?

Thanks again :).

Apple does a better job than I ever could on explaining that…
[url=http://developer.apple.com/documentation/AppleScript/Conceptual/AppleScriptLangGuide/AppleScript.9e.html#17207]http://developer.apple.com/documentation/AppleScript/Conceptual/AppleScriptLangGuide/AppleScript.9e.html#17207[/url]

To my knowledge, you cannot write a 2D array, let alone just a list to a file, it has to be coerced to a stringified datatype before writing to a file. You could, I suppose, build your variable as a delimited string and write that to a file. Then, read the file and get the text items to get your 3 sublists.

--=============================
--Build your variable and write to a file
set moo to ""

set moo to moo & {1, 2, 3} & return
set moo to moo & {4, 5, 6} & return
set moo to moo & {7, 8, 9} & return

write moo to "Mac HD:Some File"

--=============================

--=============================
--Read your file and get your data
set mooRead to read "Mac HD:Some File" as text using delimiter return
--result is a list of 3 items
--=============================

Best,