Why does a "literal" work, but not User input?

display dialog "Look up " default answer ""
set varUserEntry to text returned of result
set varLiteral to "literal"
tell application "Merriam-Webster"
	
	MWClearPaste varUserEntry -- why does it not work?
	MWClearPaste varLiteral -- works, but useless
end tell

Event Log
tell current application
display dialog "Look up " default answer “”
{text returned:“failure”, button returned:“OK”}
end tell
tell application “Merriam-Webster”
MWClearPaste “failure”
current application
MWClearPaste “failure”
MWClearPaste “literal”
end tell

[b]Using:[/b}
App is an old 2003 dictionary
Compiled in Script Editor 2.1.2 (82.1)

Model: MacBook
AppleScript: 1.10.7
Browser: Safari 531.9
Operating System: Mac OS X (10.4)

Hi, route. Welcome to MacScripter.

I’m not familiar with your app, but one possibility is the fact that with OS 10.4, your literal text is a string, whereas the text returned by ‘display dialog’ is Unicode text. Since your application is “old” (2003), it may not understand Unicode text. If that’s the problem, there’s a hack that’ll work in 10.4 to convert the Unicode text to a plain string. But if you upgrade to 10.5 ” where AppleScript uses Unicode text internally throughout ” you’ll also need to upgrade your app.

display dialog "Look up " default answer ""
set varUserEntry to text returned of result
set {text:varUserEntry} to (varUserEntry as string) -- Unicode text -> plain string hack.
set varLiteral to "literal"
tell application "Merriam-Webster"
	
	MWClearPaste varUserEntry
	MWClearPaste varLiteral
end tell

display dialog "Look up " default answer ""
set varUserEntry to text returned of result
set {text:varUserEntry} to (varUserEntry as string) -- Unicode text -> plain string hack.
tell application "Merriam-Webster"
	MWClearPaste varUserEntry
end tell

CAUTION

if you upgrade to 10.5 or 10.6, the instruction used to coerce as good old ASCII text will be inefficient.
You will have to use a more powerful tool.

It’s funny, your question was asked (and responded) last week in the forum: applescript-users@lists.apple.com

Yvan KOENIG (VALLAURIS, France.) lundi 24 août 2009 16:33:56

:lol: I skipped that thread because, very properly, it had “Webster Dictionary Application” in its subject line ” and I know nothing about that!

The hack discussed there was the even older:

set varUserEntry to «class ktxt» of (varUserEntry as record)

It works in 10.2, but errors in 10.4, as it did for route/Window Pen. It needs an additional coercion in 10.4:

set varUserEntry to «class ktxt» of (varUserEntry as string as record)

But, to reemphasise, these are hacks. They’re not officially possible. They just happen to produce certain results on certain systems.