macperl-toolbox-digest Thursday, March 11 1999 Volume 01 : Number 004 [MacPerl-Toolbox] New to programming [MacPerl-Toolbox] Fun With Compiled Scripts Re: [MacPerl-Toolbox] New to programming ---------------------------------------------------------------------- Date: Tue, 9 Mar 1999 09:50:58 EST From: ASica486@aol.com Subject: [MacPerl-Toolbox] New to programming Hello my name is Adriano and I was on the web and somehow I got kinked to MacPerl I'm going to be honest... I am not a Mac programmer but I'm learning slow on my own when I have time. Here is my question... Do I need anything else to use MacPerl or just download the leatest version and there I have the programming tool. Any response would be greatly appreciated Cheers Adriano ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" to macperl-toolbox-request@macperl.org ------------------------------ Date: Tue, 9 Mar 1999 11:39:16 -0500 From: Chris Nandor <pudge@pobox.com> Subject: [MacPerl-Toolbox] Fun With Compiled Scripts This will save your MacPerl script as a compiled AppleScript. It requires a new Mac::OSA::Simple, which I have if you want to try it. This is cool for things that require compiled AppleScripts, like OSA Menu, attached scripts to folders, ircle scripts, etc. Of course, you can also do something like: tell application "MacPerl" to Do Script alias "path:to:script" It is simple to adapt this script to do that, and I will likely do it, so people have a choice of how they want to store their compiled scripts. The alias method is probably better in most cases, actually, since you can edit the script more easily and it is less data to send via Apple Events to the MacPerl app. OTOH, if you want to distribute something, or if paths might change, and the script is not going to change much, then this method might be better. So whatever floats your boat. :) #!perl -w # p2as :) # pudge@pobox.com # 1999.03.09 use Mac::OSA::Simple; use Mac::Resources; use Mac::Memory; use strict; my($comp, $data, $res, $script, $len, $file, $text); local $/; $text = fix_text(<>) or die "No text?"; $file = $ARGV . '.scr'; CreateResFile($file) or die $^E; MacPerl::SetFileInfo('ToyS', 'osas', $file); $comp = compile_applescript($text); $data = $comp->compiled or die "No data?"; $len = length($data); $script = NewHandle($len); $script->set(0, $len, $data); $res = FSpOpenResFile $file, 0 or die $^E; AddResource($script, 'scpt', 128, 'MacPerl Script') or die $^E; UpdateResFile($res) or die $^E; CloseResFile($res); sub fix_text { # more to do than just fix " marks? my $text = shift; $text =~ s/"/\\"/g; $text = <<EOS; tell application "MacPerl" to Do Script " $text " EOS $text; } __END__ ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" to macperl-toolbox-request@macperl.org ------------------------------ Date: Tue, 9 Mar 1999 11:43:47 -0500 From: Chris Nandor <pudge@pobox.com> Subject: Re: [MacPerl-Toolbox] New to programming At 09.50 -0500 1999.03.09, ASica486@aol.com wrote: >Hello my name is Adriano and I was on the web and somehow I got kinked to >MacPerl >I'm going to be honest... I am not a Mac programmer but I'm learning slow on >my own when I have time. >Here is my question... Do I need anything else to use MacPerl or just download >the leatest version and there I have the programming tool. You want the macperl@macperl.org list, not macperl-toolbox. There are install instructions for MacPerl online in various places, including in the MacPerl book, which is available for purchase and is online in HTML at http://www.macperl.com/ptf_book/. - -- Chris Nandor mailto:pudge@pobox.com http://pudge.net/ %PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6']) ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" to macperl-toolbox-request@macperl.org ------------------------------ End of macperl-toolbox-digest V1 #4 *********************************** ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" ==== to macperl-toolbox-digest-request@macperl.org