• 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: Can't get string from
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can't get string from


  • Subject: Re: Can't get string from
  • From: "J. Stewart" <email@hidden>
  • Date: Sun, 28 Feb 2010 06:55:07 -0500

On 2/27/10 at 10:17 AM, Yuma Antoine Decaux <email@hidden> spake thusly:

I'm working on a script for blind users which will take a mouse coordinate, contain it, and place it as the value of another function to move a mouse for a drag and drop operation.

I have the current start code

tell application "Extra Suites"
	set MLocation to ES mouse location
	set MCoord to the string of MLocation
	display dialog "your mouse coordinates are" & MCoord
end tell

The script does know what the mouse coordinates are but an error tells me that it can't get the string of {304, 340}

It gets the resulted value but somehow denies me from containing into a variable.
Am i missing something here?

Yes, see Applescript Language Guide v1.3.7 page 97 on Coercion. If you don't have it, you should and can contact me off list for a copy of it. This is the last pre Snow Leopard version of the ALSG.


This line of your script is the culprit, it uses incorrect syntax:
		set MCoord to the string of MLocation

corrected syntax is:
		set MCoord to MLocation as string -- or text, "string" being deprecated

If your users are blind then a dialog isn't going to be of much use to them but here is a script that works. It also does a bit of formatting to make the dialog text presentable. What you are doing is coercing a list of numeric data into text. the phrase "as text" accomplishes this. I broke the list into separate parts to format it.

--> Script <--
tell application "Extra Suites" to set MLocation to ES mouse location
set MCoord to (item 1 of MLocation as text & ", " & item 2 of MLocation as text)
display dialog "your mouse coordinates are " & MCoord
--> /Script <--



This script does it verbally. It also takes advantage of the automatic coercion facilities of Applescript that converts the numbers when concatenating them to text.


--> Script <--
tell application "Extra Suites" to set MLocation to ES mouse location
say "Horizontal equals " & item 1 of MLocation
delay 1
say "Vertical equals " & item 2 of MLocation
--> /Script <--

Last but not least, Extra Suites is a PPC faceless background application that sadly has never been ported for the Intel Macs. Your script's user base is going to be limited by that if you plan on distributing it.

John
--
The Sufis advise us to speak only after our words have managed to pass through three gates.  At the first gate, we ask ouselves, 'Are these words true?'  If so, we let them pass on; if not, back they go.  At the second gate, we ask, 'Are they necessary?'  At the last gate, we ask, 'Are they kind?'  -Eknath Easwaran
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users


This email sent to email@hidden
References: 
 >Can't get string from (From: Yuma Antoine Decaux <email@hidden>)

  • Prev by Date: Can't get string from
  • Next by Date: QuickTimePlayerX document properties
  • Previous by thread: Can't get string from
  • Next by thread: call soap to indesign server
  • Index(es):
    • Date
    • Thread