Obtain property with tell in single sentence

I want to declare a property in a single statement, i.e. instead of


property  passw : ""
tell application "Keychain Scripting" to tell current keychain to tell (some generic key ¬
	whose name is "ApplescriptAllow") to set passW to password

do


property passw : tell application "Keychain Scripting" to tell current keychain to tell (some generic key ¬
	whose name is "ApplescriptAllow") to password

What’s the syntax here…?

In short, not supported.

What are you trying to do here. More specifically, what do you think the difference is between what you’re trying to do on one line and the two-line format.

Just a matter of economy - not a big issue !

By the way, I found this to work:


using terms from application "Keychain Scripting"
	property passW : application "Keychain Scripting"'s current keychain's (some generic key ¬
		whose name is "ApplescriptAllow")'s password
end using terms from

which requires the “using terms from” clause - so little to be gained.

If you want to compile the result of some code into the script as a property, you can also put the code into a handler, which must appear above the property declaration:

on getPassword()
	tell application "Keychain Scripting" to tell current keychain to tell (some generic key whose name is "AppleScriptAllow") to return password
end getPassword

property passw : getPassword()

This, of course, compile’s the scripter’s password into the script, which might not be the same as the user’s. For that, you need to use set anyway, so that the value’s set when the script’s run “ which means you may as well ditch the property and simply declare passw as a global. :slight_smile: