• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Keychain and text returned
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Keychain and text returned


  • Subject: Re: Keychain and text returned
  • From: Neil Faiman <email@hidden>
  • Date: Tue, 29 Mar 2005 19:27:09 -0500

I was able to reproduce the same problem.

The Keychain Scripting dictionary says that the "name" property of a key has type "string", and "display dialog" returns a value of type "Unicode text"; this is apparently the problem.

Coercing to "string" or "text" does not solve the problem. However, inserting the following line

	set keyName to asPlainText(keyName)

between the "set keyName to the text returned ..." line and the "tell application ..." line does solve the problem, where the asText handler is defined as

	on AsPlainText(textual)

(* Where 'textual' values may include plain text,'international text',
styled text, Pascal string, C string, Unicode text, and «class utf8».


Unicode characters not having a single-byte "mapping" come back as a
question mark.
*)


    	set {text:plainText} to textual as text
    	return plainText

	end AsPlainText

This solution comes from a note by Paul Berkowitz (and is attributed by him to Arthur Knapp) in a discussion titled "'Bad' characters from AS Studio text fields", March 22-23, in the AppleScript Studio mailing list. I strongly recommend reading the entire discussion, if you read that list or have access to its archives.

	-Neil Faiman


On Mar 29, 2005, at 9:19 AM, John Cochrane wrote:

In my Keychain I have a key named "server"

The following script successfully  finds the key:

set keyName to "server"
tell application "Keychain Scripting"
	tell the current keychain
		set theKey to (key 1 whose name is keyName)
	end tell
end tell

However surprisingly when the string "server" is returned from a dialog then the script fails.

set keyName to the text returned of (display dialog "What is the name of the key?" default answer "server" buttons {"OK"})
tell application "Keychain Scripting"
tell the current keychain
set theKey to (key 1 whose name is keyName)
end tell
end tell
-->Can't get key 1 of current keychain whose name = \"server\"


I'm puzzled.

John Cochrane

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Keychain and text returned (From: John Cochrane <email@hidden>)

  • Prev by Date: Re: Keychain and text returned
  • Next by Date: controlling battery charge limits
  • Previous by thread: Keychain and text returned
  • Next by thread: Re: Keychain and text returned
  • Index(es):
    • Date
    • Thread