Hello i was wondering if there is a way to have struct in applescript like they are in c.
here is an example in c.
struct file_info
{
int size;
char name;
int data;
};
how can i do that in applescript and lets say another struct calls it like this
struct png_file
{
int width;
int height;
file_info file;
};
is there any way to do that?
Are you trying to interface with a C-based library that uses structs, or do you just want an AppleScript construct that lets you use named fields as one might use structs in C?
to makeFileInfo(theName, theSize, theData)
{size:theSize, name:theName, data:theData}
end makeFileInfo
to makePNGFile(width, height, fileInfo)
{width:width, height:height, file:fileInfo}
end makePNGFile
on run
set a to makeFileInfo("foo", 10, "foobarquux") -- create a record with a handler
set b to {data:"baz", size:3, name:"bar"} -- create a record "on the fly"
display dialog "A: " & name of a & return & "B: " & name of b -- access is the same either way
set name of a to "NEWFOO"
set name of b to "BAZ"
display dialog "new A name: " & name of a & return & "new B name: " & name of b
set c to makePNGFile(10, 100, {name:"vbar"})
set d to {file:{name:"hbar"}, width:200, height:10}
display dialog "C width: " & width of c & return & "D width: " & width of d
end run
Model: iBook G4 933
AppleScript: 1.10.7
Browser: Safari 3.0.4 (523.12)
Operating System: Mac OS X (10.4)