Recent Widgets


Register for DashboardWidgets

Recent Forums Posts

Partners


iCompositions

MacDesktops.net

RSS Showcase
RSS Comments
RSS Forums

This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. Posted in: Widget Development

Passing extensive values to AppleScript

Author Message
mrsleeveless



Joined: 25 Feb 2007
Posts: 2

Posted: Sun Feb 25, 2007 - 6:20 pm    Post subject: Passing extensive values to AppleScript Reply with quote

Hey everyone,

I have a Widget that is calling bundled Applescript files.

The applescript does several things with whatever is received. For example, I will tell Applescript to create a file on the desktop, with the contents of that file being my sent value.

It works in an instance like this if contents = "Me myself and I"

widget.system("/usr/bin/osascript myscript.scpt '" + contents + "'", null)

However, it will not work if contents has a special character, like "I'll be there"

Another dilemma is sending large text chunks to this script. Take for example the contents of an email or something like a chunk of song lyrics. It doesn't send multi-line text.

Is there a way to get around this? This is the last point of my development for this widget, and its the only thing holding me back.

Any help would be great.
View user's profile Send private message Send e-mail Widgets
mrsleeveless



Joined: 25 Feb 2007
Posts: 2

Posted: Sun Feb 25, 2007 - 7:06 pm    Post subject: Reply with quote

I think the problem is if the contents variable contains the character '

Thats the single quote. Spaced it out so you could see.

Is there anyway to avoid having to replace all ' characters. It doesnt seem like a good solution to me, because I may later find out that the problem is more then one character
View user's profile Send private message Send e-mail Widgets
skippychalmers



Joined: 06 Apr 2007
Posts: 2
Location: Australia

Posted: Fri Apr 06, 2007 - 11:18 am    Post subject: Reply with quote

try escaping the character? \'
View user's profile Send private message Send e-mail Visit poster's website AIM Address Widgets
JayHD



Joined: 06 Apr 2007
Posts: 15

Posted: Fri Apr 06, 2007 - 8:14 pm    Post subject: Reply with quote

You probably want to make a function that prepares the contents to be sent as a terminal command, making sure to escape any characters which require it, (ie. quotes).
View user's profile Send private message Send e-mail Widgets
gandreas



Joined: 16 Jun 2005
Posts: 114

Posted: Sun Apr 08, 2007 - 9:49 am    Post subject: Reply with quote

And hope that it doesn't have any non-ascii characters since they won't be correctly interpreted when they get to the script, thanks to osascript expected MacRoman instead of UTF8.

osascript works fine for small simple tasks - for larger ones you really need to have a plug-in to allow for richer (and safer) interaction with your script...
View user's profile Send private message Send e-mail Widgets
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.

 
Powered by phpBB © 2001, 2002 phpBB Group