[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Fix for Alpha editor/MacPerl curly quotes bug.



At 1.53 97/2/17, Dan Herron wrote:
>At 11:37 -0800 2/12/97, Nikolaos D. Willmore wrote:
>>Greetings:
>>
>>I found that I have to use chr(211) in place of a right-side curly quote
>>(option-shift-[) or the Alpha editor fails to send the script to MacPerl.
>>It works fine if you enter the script into MacPerl directly.  The whole
>>script fails, even if the curly quotes are in a comment line, so I assume
>>it's in Alpha's perl.tcl file.  I did upgrade to the just-posted perl.tcl
>>file.

>Does anybody know anything about AppleEvents? Is this specific to Alpha? If
>not, is there some way to protect or escape curly-quotes? The chr(211)
>stuff obviously won't work in all cases.

Curly quotes is the text delimiter for AppleEvents; but the safest way to
do this that I have found is this:

#!perl
use Mac::AppleEvents;
$be = AEBuildAppleEvent('WAPI','N2AD',typeApplSignature,'TCpp',0,0,'')||die $^E;
AEPutParamDesc($be,'----',(AEBuild('TEXT(@)','bolo.usu.edu')));
print AEPrint($be);

The first line builds the event with no parameters.  The second line adds
to the event $be the parameter '----' with a value of 'bolo.usu.edu', made
into a text parameter.  The third line converts the AppleEvent named $be
into text, and you can see the curly quotes.

This is the safest way to do it (or using a similar method from Matthias'
Perl Anarchist's Cookbook) simply because if your text has curly quotes in
it, then it will mess up the delimiter.  For example, I could write this:

#!perl
use Mac::AppleEvents;
$be = AEBuildAppleEvent('WAPI','N2AD',typeApplSignature,'TCpp',0,0,'')||die $^E;
AEPutParamDesc($be,'----',(AEBuild('"bolo.usu.edu"')));
print AEPrint($be);

where the "" around bolo.usu.edu are curly.  But if the text actually had
curly quotes in it, that would obviously be a problem.

#================================================================
Chris Nandor                                      pudge@pobox.com
PGP Key 1024/B76E72AD                           http://pudge.net/
Keyfingerprint = 08 24 09 0B CE 73 CA 10  1F F7 7F 13 81 80 B6 B6