AppleScript records and Tell statements

Mikuro

Crotchety UI Nitpicker
I'm trying to create a custom record in a script, and then access its properties in a Tell statement. Like this:
Code:
set y to {high:14, low:13, permutations:12} as record
tell y
	return count
end tell
That works just fine. However, I can't access high, low or permutations that way. "return high" causes an error.

I can access the properties by saying "the high of y", but I can't use the simplified form in the tell block. The problem is that AppleScript sees "high" as the name of an undefined variable, not as a property name.

Is there any way I can make this work? Can I specify custom script-wide keywords somehow?

If necessary, of course, I can just use the lengthy form. But it's a bit of a hassle, because in this case writability is very important, as the script takes user-made statements. It'd be nice if I could just execute those statements, but if I can't get the tell block working, I'll have to run some text filters on them first.
 
Code:
set y to {high:14, low:13, permutations:12} as record
tell y
	return high of y
end tell
worked fine for me without error.
 
kainjow said:
Code:
set y to {high:14, low:13, permutations:12} as record
tell y
	return high of y
end tell
worked fine for me without error.
Yeah, but you're still using the lengthy form, the same as you would outside the Tell block. The problem is I don't want to have to say "of y".

This should work, but doesn't:
Code:
tell y
	return high
end tell
This style will work with application-defined records, like so:
Code:
tell application "Finder"
	set x to the properties of file 1
end tell
tell x
	return kind
end tell
Is there any way to use similar syntax with my custom records?
 
Back
Top