That's really cool.  I'm a lot better with Perl.  But I guess you don't 
get any of the application tie ins like you do with AppleScript.

Michael

Emmanuel. M. Decarie wrote:

> Hello,
>
> I just had this conversation on the AppleScript Studio list with Tim 
> Bumgarner, the lead developer, and thought that some people on this 
> list might be interested.
>
> If you want to use a little bit of AppleScript for manipulating the 
> UI, you could build easily Perl app with a nice Aqua interface.
>
>> À (At) 23:36 -0500 17/12/01, Emmanuel. M. Decarie écrivait (wrote) :
>>
>>>
>>>> *** 2. Can I put a Perl script or any other text file containing 
>>>> shell commands in the project that I could call from 
>>>> Application.applescript?
>>>>
>>>> Suppose I want to build an AS Studio app that will open a window to 
>>>> choose a file, and then pass the path to the file to a Perl script 
>>>> that will sort every words in the file alphabetically with the 
>>>> number of occurrences for each word, and then return back the stats 
>>>> to the user in a new window.
>>>>
>>>> - Could I embed the Perl script file in the project?
>>>> - If so, how do I get the path to this file to be able to run it 
>>>> from Application.applescript (i.e do shell script "path in to my 
>>>> Perl script")
>>>>
>>> I don't have any experience with perl, but you should be able to do 
>>> the following:
>>>
>>> 1. Create a perl script, say 'stats.perl'.
>>> 2. Add it to your project. This will typically end up in the 'Bundle 
>>> Resources' build phase which usually put's it's products into 
>>> 'Contents/Resources' inside of your built application.
>>> 3. Do the following somewhere in your script: 'tell main bundle to 
>>> set thePath to path for resource "stats" extension "perl"'.  This 
>>> will return the full POSIX path to your 'stats.perl' script that is 
>>> in your built application.
>>> 4. Pass that path to an execution of 'do shell script'. I'm not sure 
>>> how to invoke a perl script, but I think you get the idea.
>>>
>>> You can check out the 'path for' command for more variants. It 
>>> listed in the Application Suite.
>>
>>
>> Yes! This is working. I just changed the Hello World example with 
>> this script:
>>
>> on clicked theObject
>>     tell main bundle to set thePath to path for resource "stats" 
>> extension "perl"
>>     try
>>         set thePath to "\"" & thePath & "\""
>>         set r to do shell script thePath
>>         display dialog r
>>     on error msgError
>>         display dialog msgError
>>         display dialog thePath
>>     end try
>> end clicked
>>
>> And put a stats.perl file in the Resources folder with this snippet:
>>
>> #!/usr/bin/perl
>>
>> use strict;
>>
>> my $r = scalar (localtime);
>>
>> print $r;
>>
>> And then build the Hello World app and its working. The only problem 
>> that I had was that I forgot to set executable bit on the stats.perl 
>> file.
>>
>> Wow, this is very very cool!!!!
>>
>
> AppleScript Studio list:
> <http://www.lists.apple.com/mailman/listinfo/applescript-studio>




Reply via email to