Re: Keychain and text returned
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