image
image

|


Go Back   macosx.com > Design, Media, Programming & Scripting > Software Programming & Web Scripting

Reply
 
Thread Tools
  #1  
Old November 9th, 2005, 03:18 PM
Mikuro's Avatar
Crotchety UI Nitpicker
 
Join Date: Mar 2005
Posts: 2,442
Thanks: 2
Thanked 4 Times in 4 Posts
Mikuro is on a distinguished road
AppleScript records and Tell statements

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.
__________________
Mac mini — 1.25GHz G4, 1GB RAM — OS 10.5.2

I'm now a four-browser man. How on earth did this happen?!

Useful programs: PithHelmet, Butler, ffmpegX, VLC, Perian, Tofu, Wcalc
Reply With Quote
  #2  
Old November 10th, 2005, 05:55 PM
Registered User
 
Join Date: Nov 2000
Posts: 948
Thanks: 0
Thanked 0 Times in 0 Posts
kainjow is on a distinguished road
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.
Reply With Quote
  #3  
Old November 10th, 2005, 06:33 PM
Mikuro's Avatar
Crotchety UI Nitpicker
 
Join Date: Mar 2005
Posts: 2,442
Thanks: 2
Thanked 4 Times in 4 Posts
Mikuro is on a distinguished road
Quote:
Originally Posted by kainjow
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?
__________________
Mac mini — 1.25GHz G4, 1GB RAM — OS 10.5.2

I'm now a four-browser man. How on earth did this happen?!

Useful programs: PithHelmet, Butler, ffmpegX, VLC, Perian, Tofu, Wcalc
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 03:05 PM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.