Re: Running JavaScript via AppleScript Problems
Re: Running JavaScript via AppleScript Problems
- Subject: Re: Running JavaScript via AppleScript Problems
- From: Mark Thomas <email@hidden>
- Date: Sun, 19 Nov 2006 17:36:19 +0000
- Organization: Coderus Ltd
Hi Andrew,
Thanks, but what's I tried, but that doesn't seem to work, which I find
strange :-( as I'm specifying the extra '\' so to be in embedded, which I'
wondering now whether there is another way of to doing.
Thanks
Mark.
> Since both the JavaScript and AppleScript use the same delimiters you
> need to double-escape them. Otherwise your line:
>
> Do JavaScript "where.onStatusDone(0, 'my result is "Yes".'); "
>
> is broken down to:
>
> Do JavaScript "where.onStatusDone(0, 'my result is "
> Yes
> ".'); "
>
> At the very least you need to escape the quotes inside the JavaScript
> command so that AppleScript passes them to JavaScript rather than
> using it itself:
>
> Do JavaScript "where.onStatusDone(0, 'my result is \"Yes\".'); "
>
> Andrew
> :)
>
> On Nov 17, 2006, at 2:48 PM, Mark Thomas wrote:
>
>> Hi,
>> I'm deliberately wanting to have the parameter strings to contain
>> encoded/escaped characters like returns & lines feeds (\r & \n).
>>
>> But it seems like that you cannot embedded string within strings
>> also.
>>
>> where.onStatusDone(0, 'my result is "Yes".');
>>
>> In above example that is with a do JavaScript (I'm leaving out the
>> 'tell
>> application' ..etc 'end tell' to simplify the below example) i.e.
>>
>> Do JavaScript "where.onStatusDone(0, 'my result is "Yes".'); "
>>
>> But I don't seem to be able to Apple Script to allow escape
>> character.
>>
>> Thanks
>> Mark.
>>
>>>
>>> Message: 2
>>> Date: Fri, 17 Nov 2006 20:27:09 +0100
>>> From: Emmanuel <email@hidden>
>>> Subject: Re: Running JavaScript via AppleScript Problems
>>> To: <email@hidden>
>>> Message-ID: <p06230908c183bd3ccd7a@[10.0.1.5]>
>>> Content-Type: text/plain; charset="us-ascii" ; format="flowed"
>>>
>>> At 8:20 PM +0100 11/17/06, Emmanuel wrote:
>>>> At 6:30 PM +0000 11/17/06, Mark Thomas wrote:
>>>>> (gdb) print scriptText
>>>>> $1 = 0x5bcd10 "tell application \"Safari\"\n do JavaScript \"var
>>>>> where; if
>>>>> (typeof(IBISmain)!='undefined') where=IBISmain; else where=window;
>>>>> where.onStatusDone(0, 'my result is \\\"Yes\\\" \\\n.');\" in
>>>>> document 1\n
>>>>> end tell"
>>>>
>>>> Maybe this is no good because the javascript ends with two newlines
>>>> in the middle, look at your actual javascript:
>>>>
>>>> var where; if
>>>> (typeof(IBISmain)!='undefined') where=IBISmain; else where=window;
>>>> where.onStatusDone(0, 'my result is "Yes" .');
>>>
>>> The list server brought a correction :-) to my post. In my original
>>> post, which corresponds to the OP's script above, there is a new line
>>> here:
>>>
>>>> where.onStatusDone(0, 'my result is "Yes"
>>>
>>> (new line)
>>>
>>>> .');
>>>
>>> Emmanuel
>>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> AppleScript-Users mailing list (applescript-
>> email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>> Archives: http://lists.apple.com/mailman//archives/applescript-users
>>
>> 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:
Archives: http://lists.apple.com/mailman//archives/applescript-users
This email sent to email@hidden