perl.macperl.toolbox http://www.nntp.perl.org/group/perl.macperl.toolbox/ ... Copyright 1998-2014 perl.org Sat, 22 Nov 2014 12:34:22 +0000 ask@perl.org Re: [MacPerl-Toolbox] read resource fork by David Arnold No, this is for Classic OS. I can&#39;t figure out how to get at the fork<br/>data directly.<br/><br/>David<br/><br/>On Thu, January 24, 2008 19:31, Chris Nandor wrote:<br/>* On Jan 24, 2008, at 19:11, David Arnold wrote:<br/>*<br/>*&gt; How do i read an entire resource fork, similar to reading the data<br/>*&gt; fork,<br/>*&gt; irrespective of individual resources?<br/>*<br/>* Is this for Mac OS X? If so, you might be able to just do:<br/>*<br/>* open my $rsrc, &#39;&lt;&#39;, &quot;$filepath/rsrc&quot;;<br/>*<br/>* It&#39;s an easy shortcut to get at the raw fork.<br/>*<br/>* Also, if this is for Mac OS X, you might find the macosx@perl.org list<br/>* of more use.<br/>*<br/>* --<br/>* Chris Nandor pudge@pobox.com http://pudge.net/<br/>* Slashdot / SourceForge pudge@slashdot.org http://slashdot.org/<br/>*<br/>*<br/><br/><br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2008/01/msg106.html Tue, 29 Jan 2008 16:33:13 +0000 Re: [MacPerl-Toolbox] read resource fork by Chris Nandor On Jan 24, 2008, at 19:11, David Arnold wrote:<br/><br/>&gt; How do i read an entire resource fork, similar to reading the data <br/>&gt; fork,<br/>&gt; irrespective of individual resources?<br/><br/>Is this for Mac OS X? If so, you might be able to just do:<br/><br/> open my $rsrc, &#39;&lt;&#39;, &quot;$filepath/rsrc&quot;;<br/><br/>It&#39;s an easy shortcut to get at the raw fork.<br/><br/>Also, if this is for Mac OS X, you might find the macosx@perl.org list <br/>of more use.<br/><br/>-- <br/>Chris Nandor pudge@pobox.com http://pudge.net/<br/>Slashdot / SourceForge pudge@slashdot.org http://slashdot.org/<br/><br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2008/01/msg105.html Thu, 24 Jan 2008 19:31:35 +0000 read resource fork by David Arnold How do i read an entire resource fork, similar to reading the data fork,<br/>irrespective of individual resources?<br/><br/>I admit i am somewhat less than a novice to the Macintosh Toolbox, so i<br/>can&#39;t even figure out how to read individual resources; i&#39;ve perused and<br/>tried out the commands in MacPerl for that but i can&#39;t get them to work. <br/>However, there appear to be no commands to do a simple read of the fork<br/>itself as if it were mere data.<br/><br/>If i could do this, i can load the resources myself (i know how to parse<br/>the resource map and know the resource fork format), but mainly i want to<br/>slurp two forks for comparison purposes.<br/><br/>David<br/><br/><br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2008/01/msg104.html Thu, 24 Jan 2008 19:11:51 +0000 "how to know the contents of exe file" by vrpprasad Hi,<br/> I want to find out what r the documents contain in exe file(through<br/>PERL) depends on that I have to execute my programe.Could anyone help me<br/>in this <br/><br/><br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2004/09/msg103.html Tue, 07 Sep 2004 03:22:23 +0000 MacPerl / GUI by John Eremic Hello World--<br/><br/>I am not new to Perl but I am new to MacPerl, and to Mac development in<br/>general.<br/><br/>My task is to write a simple text-munging app. Easy enough. The trick is<br/>that it needs a Mac GUI (to browse for destination/target files and check<br/>off a few options). I could do this for Win32 using Perl/Tk, but I am<br/>unsure how to approach this for Mac.<br/><br/>As I understand it MacPerl has hooks into Mac&#39;s Toolbox, but I have found<br/>scant documentation on MacPerl/Toolbox or on MacPerl in general.<br/><br/>- How viable is creating (simple) Mac GUI apps using only MacPerl?<br/>- What Perl-&gt;Mac binary compilers exist?<br/>- Where can I find the best documentation on MacPerl::Toolbox?<br/><br/><br/>Thanks<br/>Pliny<br/><br/><br/><br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2004/04/msg102.html Thu, 29 Apr 2004 09:41:08 +0000 Mac::Dialog modify Text on a Button by Kummerant, Stefan Hallo,<br/>after several hours staering at this peanuts programm and searches in the<br/>net, I hope to get some help here.<br/>This GUI has 2 Buttons: One is only to close the Dialogbox tidy, and the<br/>other should change it`s marking from &quot;Text_alt&quot; to &quot;neuer_Text&quot;.<br/>But, if I click on &quot;Text_alt&quot; my MAC stalls.<br/>Best Regards Stefan<br/><br/>Die GUI hat 2 Knoepfe: Einer ist nur dazu da die Dialogbox ordentlich zu<br/>schliessen. Der andere soll nur die Beschriftung von &quot;Text_alt&quot; zu<br/>&quot;neuer_Text&quot; aendern.<br/>Aber, wenn ich darauf klicke haengt sich mein MAC auf.<br/>Im voraus vielen Dank Stefan<br/><br/>#!perl -w<br/>use Mac::Windows;<br/>use Mac::QuickDraw;<br/>use Mac::Events;<br/>use Mac::Dialogs;<br/>$dlg =3D MacDialog-&gt;new(<br/> Rect-&gt;new(50,50,140,120), &#39;minidialog&#39;, 1, movableDBoxProc(), 0,<br/> [ kButtonDialogItem(), Rect-&gt;new(10,10,80,30), &#39;Text_alt&#39; ],<br/> [ kButtonDialogItem(), Rect-&gt;new(10,40,80,60), &#39;ende&#39; ],<br/>);<br/><br/>$dlg-&gt;item_hit(1 =3D&gt; \&amp;d1);<br/>$dlg-&gt;item_hit(2 =3D&gt; \&amp;d2);<br/><br/><br/>while ($dlg-&gt;window()) {<br/> WaitNextEvent();<br/>}<br/><br/><br/>END {<br/> $dlg-&gt;dispose() if defined($dlg);<br/>}<br/><br/><br/>sub draw_it {}<br/><br/><br/>sub d1{<br/> my ($dlg, $item) =3D @_;<br/> $dlg-&gt;item_text($item, &quot;neuer_Text&quot;);<br/> return(1);<br/>}<br/><br/><br/>sub d2{<br/> #### Ende Taste ####<br/> my ($dlg, $item) =3D @_;<br/> $dlg-&gt;dispose();<br/> return(1);<br/>}<br/><br/><br/>__END__<br/><br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2004/04/msg101.html Fri, 16 Apr 2004 08:11:35 +0000 Re: [MacPerl] Re: Timezone information by Detlef Lindenthal Rick Measham wrote:<br/><br/>&gt; In article &lt;pudge-F548E6.07445406052003@onion.valueclick.com&gt;,<br/>&gt; pudge@pobox.com (Chris Nandor) wrote:<br/>&gt;<br/>&gt; &gt; In article &lt;BADC383D.47B%rickm@iSite.net.au&gt;,<br/>&gt; &gt; rickm@iSite.net.au (Rick Measham) wrote:<br/>&gt; &gt;<br/>&gt; &gt; &gt; I figure that as I&#39;ve set my timezone in the system, there must be some way<br/>&gt; &gt; &gt; to get it back using MacPerl.<br/>&gt; &gt; &gt;<br/>&gt; &gt; &gt; I figure there&#39;s either an OSA hook that will tell me what it is, or there&#39;s<br/>&gt; &gt; &gt; a toolbox call that I can (somehow) make.<br/>&gt; &gt;<br/>&gt; &gt; #!perl<br/>&gt; &gt; use Time::Local;<br/>&gt; &gt; $diff = (timelocal(localtime) - timelocal(gmtime)) / 36;<br/>&gt; &gt; $diff = sprintf &quot;%+0.4d&quot;, $diff; # add sign, leading zero(es)<br/>&gt; &gt; print $diff;<br/>&gt; &gt;<br/>&gt; &gt; That will give you the standard TZ offset (e.g., &quot;-0400&quot;).<br/>&gt;<br/>&gt; Sorry Chris, I didn&#39;t explain myself too well. I&#39;m looking for the name<br/>&gt; of the zone. It seems to be stored in the resource fork of &#39;Date &amp; Time<br/>&gt; Preferences&#39; (possibly ID256 of the &#39;pref&#39; resources), but it&#39;s not in<br/>&gt; plain text. Maybe its an offset. Any ideas? Is it anywhere useful, or do<br/>&gt; I have to work out how this preferences file is encoded?<br/>&gt;<br/>&gt; Cheers!<br/>&gt; Rick<br/><br/>Given the time zone offset, you can derive the time zone name from<br/> http://timeanddate.com/time/abbrevations.html ;<br/>put those names into one perl list and call that list with the appropriate index.<br/>If those names are not enough, look at<br/> http://worldtimezone.com/wtz-names/timezonenames.html.<br/><br/>Good luck!<br/><br/>Detlef<br/><br/><br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2003/05/msg100.html Tue, 06 May 2003 14:59:14 +0000 [MacPerl-Toolbox] Re: Timezone information by Chris Nandor At 22:46 +1000 2003.05.06, Rick Measham wrote:<br/>&gt;Sorry Chris, I didn&#39;t explain myself too well. I&#39;m looking for the name<br/>&gt;of the zone. It seems to be stored in the resource fork of &#39;Date &amp; Time<br/>&gt;Preferences&#39; (possibly ID256 of the &#39;pref&#39; resources), but it&#39;s not in<br/>&gt;plain text. Maybe its an offset. Any ideas? Is it anywhere useful, or do<br/>&gt;I have to work out how this preferences file is encoded?<br/><br/>I don&#39;t see that data in the pref resources, any of them. But it may work<br/>for you. Here&#39;s some code to get the resource data.<br/><br/> #!perl<br/> use File::Spec::Functions;<br/> use Mac::Files;<br/> use Mac::Memory;<br/> use Mac::Resources;<br/><br/> my $file = catfile(<br/> FindFolder(kOnSystemDisk, kPreferencesFolderType),<br/> &#39;Date &amp; Time Preferences&#39;<br/> );<br/><br/> my $rsfile = FSpOpenResFile($file, 0);<br/> my $rsrc = GetResource(&#39;pref&#39;, 256);<br/> print $rsrc-&gt;get;<br/><br/> CloseResFile($rsfile);<br/><br/><br/>-- <br/>Chris Nandor pudge@pobox.com http://pudge.net/<br/>Open Source Development Network pudge@osdn.com http://osdn.com/<br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2003/05/msg99.html Tue, 06 May 2003 06:47:03 +0000 Re: Timezone information by Rick Measham In article &lt;pudge-F548E6.07445406052003@onion.valueclick.com&gt;,<br/> pudge@pobox.com (Chris Nandor) wrote:<br/><br/>&gt; In article &lt;BADC383D.47B%rickm@iSite.net.au&gt;,<br/>&gt; rickm@iSite.net.au (Rick Measham) wrote:<br/>&gt; <br/>&gt; &gt; I figure that as I&#39;ve set my timezone in the system, there must be some way<br/>&gt; &gt; to get it back using MacPerl.<br/>&gt; &gt; <br/>&gt; &gt; I figure there&#39;s either an OSA hook that will tell me what it is, or there&#39;s<br/>&gt; &gt; a toolbox call that I can (somehow) make.<br/>&gt; <br/>&gt; #!perl<br/>&gt; use Time::Local;<br/>&gt; $diff = (timelocal(localtime) - timelocal(gmtime)) / 36;<br/>&gt; $diff = sprintf &quot;%+0.4d&quot;, $diff; # add sign, leading zero(es)<br/>&gt; print $diff;<br/>&gt; <br/>&gt; That will give you the standard TZ offset (e.g., &quot;-0400&quot;).<br/><br/>Sorry Chris, I didn&#39;t explain myself too well. I&#39;m looking for the name <br/>of the zone. It seems to be stored in the resource fork of &#39;Date &amp; Time <br/>Preferences&#39; (possibly ID256 of the &#39;pref&#39; resources), but it&#39;s not in <br/>plain text. Maybe its an offset. Any ideas? Is it anywhere useful, or do <br/>I have to work out how this preferences file is encoded?<br/><br/>Cheers!<br/>Rick<br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2003/05/msg98.html Tue, 06 May 2003 06:03:04 +0000 Re: Timezone information by Chris Nandor In article &lt;BADC383D.47B%rickm@iSite.net.au&gt;,<br/> rickm@iSite.net.au (Rick Measham) wrote:<br/><br/>&gt; I figure that as I&#39;ve set my timezone in the system, there must be some way<br/>&gt; to get it back using MacPerl.<br/>&gt; <br/>&gt; I figure there&#39;s either an OSA hook that will tell me what it is, or there&#39;s<br/>&gt; a toolbox call that I can (somehow) make.<br/><br/> #!perl<br/> use Time::Local;<br/> $diff = (timelocal(localtime) - timelocal(gmtime)) / 36;<br/> $diff = sprintf &quot;%+0.4d&quot;, $diff; # add sign, leading zero(es)<br/> print $diff;<br/><br/>That will give you the standard TZ offset (e.g., &quot;-0400&quot;).<br/><br/>-- <br/>Chris Nandor pudge@pobox.com http://pudge.net/<br/>Open Source Development Network pudge@osdn.com http://osdn.com/<br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2003/05/msg97.html Tue, 06 May 2003 04:44:55 +0000 Timezone information by Rick Measham I figure that as I&#39;ve set my timezone in the system, there must be some way<br/>to get it back using MacPerl.<br/><br/>I figure there&#39;s either an OSA hook that will tell me what it is, or there&#39;s<br/>a toolbox call that I can (somehow) make.<br/><br/>Any gurus out there able to help me?<br/><br/>Cheers!<br/>Rick<br/><br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2003/05/msg96.html Mon, 05 May 2003 03:57:17 +0000 Re: [MacPerl-Toolbox] unknown Mac::Sound error by Chris Nandor At 02:04 -0800 2003.03.26, Nicholas G. Thornton wrote:<br/>&gt;Hello, I&#39;m a newbie to the mac toolbox but I figured I&#39;d jump right in. I&#39;m<br/>&gt;trying to use Mac::Sound::SndStartFilePlay() but I get an error:# OS error -51<br/>&gt;(Error message file not available). What does it mean, and how can I fix it?<br/><br/>-51 is refnum error.<br/><br/>I&#39;ve never used this API from MacPerl though, so I am not sure what to do,<br/>but as noted in the other email, try fileno() on the filehandle after<br/>opening it. You never know. :)<br/><br/>-- <br/>Chris Nandor pudge@pobox.com http://pudge.net/<br/>Open Source Development Network pudge@osdn.com http://osdn.com/<br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2003/03/msg95.html Wed, 26 Mar 2003 04:26:10 +0000 unknown Mac::Sound error by Nicholas.G.Thornton Hello, I&#39;m a newbie to the mac toolbox but I figured I&#39;d jump right in. I&#39;m<br/>trying to use Mac::Sound::SndStartFilePlay() but I get an error:# OS error -51<br/>(Error message file not available). What does it mean, and how can I fix it?<br/><br/>It might be a problem with the file reference number thing (which I don&#39;t<br/>understand) but looking through the archives I found something implying that it<br/>should work. In case it helps the code follows.<br/><br/>Thanks in advance,<br/>~wren<br/><br/>#!perl -w<br/>use strict;<br/>use Mac::Sound;<br/>use vars qw($filename $file_ref_number $ch $chan $sel $theSelection);<br/>my $ch = 0; $chan = bless \$ch, &quot;SndChannel&quot;;<br/>my $sel = 0; $theSelection = bless \$sel, &quot;AudioSelection&quot;;<br/><br/>$filename = shift @ARGV; # for argument&#39;s sake<br/>&amp;PlayAiff($filename);<br/>print &#39;Test Done!&#39;;<br/><br/>sub PlayAiff {<br/> my $filename = shift;<br/> open (SOUND, $filename) or die &quot;Couldn&#39;t open $filename&quot;;<br/> SndStartFilePlay($chan, \*SOUND, 0, 0, $theSelection, 0, 0) or die $^E;<br/> close SOUND;<br/>}<br/>__END__<br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2003/03/msg94.html Wed, 26 Mar 2003 02:04:45 +0000 Re: [MacPerl-Toolbox] strip the resource fork by Bart Lateur On Fri, 21 Mar 2003 18:11:49 -0500, Chris Nandor wrote:<br/><br/>&gt;Without testing, I am fairly certain the fork will be gone.<br/><br/>OK, I have tested it. The resource fork appears indeed to have gone.<br/><br/>-- <br/> Bart.<br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2003/03/msg93.html Sat, 22 Mar 2003 00:18:00 +0000 Re: [MacPerl-Toolbox] strip the resource fork by Chris Nandor http://archive.develooper.com/macperl@perl.org/msg02178.html<br/><br/>&gt;Here&#39;s another way, if you really want to destroy it and avoid copying:<br/>&gt;<br/>&gt; use Fcntl ();<br/>&gt; use POSIX ();<br/>&gt;<br/>&gt; my $resfork = POSIX::open($file,<br/>&gt; &amp;POSIX::O_WRONLY | &amp;POSIX::O_TRUNC | &amp;Fcntl::O_RSRC<br/>&gt; );<br/>&gt; POSIX::close($resfork);<br/>&gt;<br/>&gt;This will truncate the resource fork to size 0, which essentially deletes it.<br/><br/>Without testing, I am fairly certain the fork will be gone. You can test<br/>by attempting to open the file in ResEdit to see if it asks if you want to<br/>create a new resource fork for the file.<br/><br/>-- <br/>Chris Nandor pudge@pobox.com http://pudge.net/<br/>Open Source Development Network pudge@osdn.com http://osdn.com/<br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2003/03/msg92.html Fri, 21 Mar 2003 15:12:13 +0000 Re: [MacPerl-Toolbox] strip the resource fork by Jeff Lowrey At 11:33 PM +0100 3/21/03, Bart Lateur wrote:<br/>&gt;A quick question... what&#39;s a simple, proper way to strip the resource<br/>&gt;fork from files? In this case, it&#39;s all JPEG files, where Photoshop<br/>&gt;attached an icon to.<br/>&gt;<br/>&gt;I&#39;m pretty sure something involving Posix::open with use of the<br/>&gt;Fcntl::O_RSRC flag could help... (see Mac::Conversions, on CPAN), but<br/>&gt;details are still vague to me, and I want to make sure the resource fork<br/>&gt;is completely gone, not just empty.<br/><br/>Just use normal file operations to stream the data fork into a new file.<br/><br/>-jeff lowrey<br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2003/03/msg91.html Fri, 21 Mar 2003 15:00:24 +0000 strip the resource fork by Bart Lateur A quick question... what&#39;s a simple, proper way to strip the resource<br/>fork from files? In this case, it&#39;s all JPEG files, where Photoshop<br/>attached an icon to.<br/><br/>I&#39;m pretty sure something involving Posix::open with use of the<br/>Fcntl::O_RSRC flag could help... (see Mac::Conversions, on CPAN), but<br/>details are still vague to me, and I want to make sure the resource fork<br/>is completely gone, not just empty.<br/><br/>-- <br/> Bart.<br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2003/03/msg90.html Fri, 21 Mar 2003 14:33:09 +0000 Re: [MacPerl-Toolbox] Sound Manager and "file reference numbers" by Chris Nandor At 11:01 -0500 2002.12.27, Elliott Moreton wrote:<br/>&gt;I&#39;m running 5.6.1b3 on an iBook.<br/><br/>FWIW, MacPerl 5.6.1r2 is the most recent release. r1 was released in March.<br/><br/><br/>&gt;I&#39;m trying to get a MacPerl script to<br/>&gt;play AIFF files, using the SndStartFilePlay function:<br/>&gt;<br/>&gt; use Mac::Sound;<br/>&gt;<br/>&gt; $sounddir = &quot;Macintosh HD:Moreton:exp14:SW:testsounds&quot;;<br/>&gt;<br/>&gt; $infile = &quot;$sounddir:000.aiff&quot;;<br/>&gt; open (IN, $infile) || die &quot;Couldn&#39;t open $infile&quot;;<br/>&gt;<br/>&gt; $kBufferSize = 20000;<br/>&gt;<br/>&gt; $err = SndStartFilePlay (0, IN, 0, $kBufferSize, 0, 0, 0, 0);<br/>&gt;<br/>&gt; print &quot;Error: $err\n&quot;;<br/>&gt;<br/>&gt;<br/>&gt;When I run this, I get the message:<br/>&gt;<br/>&gt;<br/>&gt; #Usage: Mac::Sound::SndStartFilePlay(chan, fRefNum, resNum,<br/>&gt;bufferSize, theSelection, theCompletion=0, async==false).<br/>&gt; File &#39;Dev:Pseudo&#39;; Line 10<br/>&gt;<br/>&gt;There isn&#39;t any MacPerl documentation on SndStartFilePlay (not even in<br/>&gt;Sound.pm), but Inside Macintosh documents it for C (Sound Reference,<br/>&gt;Chapter 1, pp. 37f), and the only thing I can see that I might be doing<br/>&gt;wrong is that SndStartFilePlay might want the file to be identified with a<br/>&gt;&quot;file reference number&quot; rather than the filehandle I&#39;m using right now.<br/>&gt;What is a &quot;file reference number&quot;, and how do I set one up?<br/><br/>I don&#39;t really know the answer, but would guess fileno(IN), perhaps.<br/><br/>At 12:36 -0500 2002.12.27, Elliott Moreton wrote:<br/>&gt;Inside Macintosh says that in order to have the whole file played, you<br/>&gt;should pass SndStartFilePlay a NIL for a parameter called theSelection,<br/>&gt;which is of type AudioSelection (Ch. 2, &quot;Using the Sound Manager&quot;, p.<br/>&gt;2-53). MacPerl won&#39;t accept 0, &#39;&#39;, (), [], or {} as a null value for this<br/>&gt;parameter:<br/>&gt;<br/>&gt; use Mac::Sound;<br/>&gt;<br/>&gt; $sounddir = &quot;Macintosh HD:Moreton:exp14:SW:testsounds&quot;;<br/>&gt;<br/>&gt; $infile = &quot;$sounddir:000.aiff&quot;;<br/>&gt; open (IN, $infile) || die &quot;Couldn&#39;t open $infile&quot;;<br/>&gt;<br/>&gt; $Chan = SndNewChannel (sampledSynth (), initMono (), 0);<br/>&gt; $kBufferSize = 20000;<br/>&gt;<br/>&gt; $err = SndStartFilePlay ($Chan, IN, 0, $kBufferSize, &#39;&#39;, 0, 0);<br/>&gt; ^<br/>&gt; |<br/>&gt; theSelection<br/>&gt;<br/>&gt;The error I get is<br/>&gt;<br/>&gt; # theSelection is not of type AudioSelection<br/>&gt;<br/>&gt;The Sound.pm code section on SndStartFilePlay has the following variable<br/>&gt;declarations:<br/>&gt;<br/>&gt; SndChannel chan<br/>&gt; short fRefNum (filehandle seems to work)<br/>&gt; short resNum (0, since this is a file, not a resource)<br/>&gt; long bufferSize<br/>&gt; AudioSelection &amp;theSelection<br/>&gt; SV *theCompletion<br/>&gt; Boolean async<br/>&gt;<br/>&gt;Can anyone see what the problem is? I&#39;m sure this is extremely basic, but<br/>&gt;I&#39;m baffled.<br/><br/>Again, I am not sure; I can look later when I get some spare time.<br/><br/>-- <br/>Chris Nandor pudge@pobox.com http://pudge.net/<br/>Open Source Development Network pudge@osdn.com http://osdn.com/<br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2002/12/msg89.html Fri, 27 Dec 2002 10:16:33 +0000 Re: [MacPerl-Toolbox] Sound Manager and "file reference numbers" by Elliott Moreton Hi,<br/><br/>Off-list help has partially solved the problem; however, another lurks <br/>beyond it. <br/><br/>Inside Macintosh says that in order to have the whole file played, you<br/>should pass SndStartFilePlay a NIL for a parameter called theSelection,<br/>which is of type AudioSelection (Ch. 2, &quot;Using the Sound Manager&quot;, p.<br/>2-53). MacPerl won&#39;t accept 0, &#39;&#39;, (), [], or {} as a null value for this <br/>parameter:<br/><br/> use Mac::Sound;<br/> <br/> $sounddir = &quot;Macintosh HD:Moreton:exp14:SW:testsounds&quot;;<br/><br/> $infile = &quot;$sounddir:000.aiff&quot;;<br/> open (IN, $infile) || die &quot;Couldn&#39;t open $infile&quot;;<br/><br/> $Chan = SndNewChannel (sampledSynth (), initMono (), 0);<br/> $kBufferSize = 20000;<br/><br/> $err = SndStartFilePlay ($Chan, IN, 0, $kBufferSize, &#39;&#39;, 0, 0);<br/> ^<br/> |<br/> theSelection<br/><br/>The error I get is <br/><br/> # theSelection is not of type AudioSelection<br/><br/>The Sound.pm code section on SndStartFilePlay has the following variable <br/>declarations:<br/><br/> SndChannel chan<br/> short fRefNum (filehandle seems to work)<br/> short resNum (0, since this is a file, not a resource)<br/> long bufferSize<br/> AudioSelection &amp;theSelection<br/> SV *theCompletion<br/> Boolean async<br/><br/>Can anyone see what the problem is? I&#39;m sure this is extremely basic, but <br/>I&#39;m baffled.<br/><br/>Thanks,<br/>Elliott Moreton<br/><br/><br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2002/12/msg88.html Fri, 27 Dec 2002 09:29:30 +0000 Sound Manager and "file reference numbers" by Elliott Moreton Hi all --<br/><br/>I&#39;m running 5.6.1b3 on an iBook. I&#39;m trying to get a MacPerl script to <br/>play AIFF files, using the SndStartFilePlay function:<br/><br/> use Mac::Sound;<br/><br/> $sounddir = &quot;Macintosh HD:Moreton:exp14:SW:testsounds&quot;;<br/><br/> $infile = &quot;$sounddir:000.aiff&quot;;<br/> open (IN, $infile) || die &quot;Couldn&#39;t open $infile&quot;;<br/><br/> $kBufferSize = 20000;<br/><br/> $err = SndStartFilePlay (0, IN, 0, $kBufferSize, 0, 0, 0, 0);<br/><br/> print &quot;Error: $err\n&quot;;<br/><br/><br/>When I run this, I get the message:<br/><br/><br/> #Usage: Mac::Sound::SndStartFilePlay(chan, fRefNum, resNum, <br/>bufferSize, theSelection, theCompletion=0, async==false).<br/> File &#39;Dev:Pseudo&#39;; Line 10<br/><br/>There isn&#39;t any MacPerl documentation on SndStartFilePlay (not even in <br/>Sound.pm), but Inside Macintosh documents it for C (Sound Reference, <br/>Chapter 1, pp. 37f), and the only thing I can see that I might be doing <br/>wrong is that SndStartFilePlay might want the file to be identified with a <br/>&quot;file reference number&quot; rather than the filehandle I&#39;m using right now. <br/>What is a &quot;file reference number&quot;, and how do I set one up? <br/><br/><br/>Many thanks,<br/>Elliott Moreton<br/><br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2002/12/msg87.html Fri, 27 Dec 2002 07:55:30 +0000 Re: [MacPerl-Toolbox] Sound Manager Toolbox docs? by Chris Nandor At 18:25 -0500 2002.11.10, Elliott Moreton wrote:<br/>&gt;&gt; Note also that in Carbon, you don&#39;t play sounds from files; Apple<br/>&gt;&gt; recommends instead to use the QuickTime API.<br/>&gt;<br/>&gt;Must I use Carbon if my Mac has it? All I really want to do is get a<br/>&gt;one-channel sound sample with known sampling rate into a one-dimensional<br/>&gt;array and then play it through the headphones.<br/><br/>No, you are not required to use Carbon, that was merely an aside, in case<br/>it applied. You can use whatever APIs are available: on Mac OS, you can<br/>use the standard Mac OS API, or the Carbon API. On Mac OS X, you can use<br/>the standard Mac OS API, but only under Classic; you can use the Carbon API<br/>or Cocoa API otherwise.<br/><br/>So in MacPerl, yes, I think you can play a file. I don&#39;t know how offhand,<br/>but hopefully the information I pointed you to will help.<br/><br/>-- <br/>Chris Nandor pudge@pobox.com http://pudge.net/<br/>Open Source Development Network pudge@osdn.com http://osdn.com/<br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2002/11/msg86.html Sun, 10 Nov 2002 19:34:48 +0000 Re: [MacPerl-Toolbox] Sound Manager Toolbox docs? by Elliott Moreton On Sun, 10 Nov 2002, Chris Nandor wrote:<br/><br/>&gt; At 17:25 -0500 2002.11.10, Elliott Moreton wrote:<br/>&gt; &gt;I&#39;d like to have a MacPerl 5.6.1b3 script play a sound file (not a<br/>&gt; &gt;resource, but a file; .wav, .aiff, or .raw) on a Power Book.<br/>&gt; <br/>&gt; Any reason you aren&#39;t using MacPerl 5.6.1r1? It&#39;s the most recent, and the<br/>&gt; beta versions are not supported.<br/><br/>I was following your advice in<br/><br/> http://archive.develooper.com/macperl@perl.org/msg01725.html<br/><br/>because of a problem with cpan-max. I suppose the message is well out of <br/>date.<br/><br/>&gt; I don&#39;t know why the Help menu doesn&#39;t show it (I&#39;ll look into it), but<br/>&gt; going to Shuck and the Go -&gt; Lookup ... menu item and entering &quot;Mac::Sound&quot;<br/>&gt; will give you the docmentation, which tells you two things:<br/><br/>Ah. OK. Didn&#39;t know what kind of argument Lookup wanted; I&#39;d tried <br/>&quot;Sound&quot; with no success.<br/><br/>&gt; Note also that in Carbon, you don&#39;t play sounds from files; Apple<br/>&gt; recommends instead to use the QuickTime API.<br/><br/>Must I use Carbon if my Mac has it? All I really want to do is get a<br/>one-channel sound sample with known sampling rate into a one-dimensional<br/>array and then play it through the headphones.<br/><br/>Many thanks,<br/>em<br/><br/><br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2002/11/msg85.html Sun, 10 Nov 2002 15:24:39 +0000 Re: [MacPerl-Toolbox] Sound Manager Toolbox docs? by Chris Nandor At 17:25 -0500 2002.11.10, Elliott Moreton wrote:<br/>&gt;I&#39;d like to have a MacPerl 5.6.1b3 script play a sound file (not a<br/>&gt;resource, but a file; .wav, .aiff, or .raw) on a Power Book.<br/><br/>Any reason you aren&#39;t using MacPerl 5.6.1r1? It&#39;s the most recent, and the<br/>beta versions are not supported.<br/><br/><br/>&gt;However, I can&#39;t find any documentation on the MacPerl Sound Manager<br/>&gt;Toolbox Module. When I go to the menu bar and choose Help : Macintosh<br/>&gt;Toolbox Manager : Sound Manager (which should bring up a man page in<br/>&gt;Shuck), I get &#39;Can&#39;t open that file, because a &quot;Directory or File not<br/>&gt;found&quot; error occurred&#39;. Other Toolbox man pages come up just fine. A<br/>&gt;Google search on &quot;MacPerl &#39;Sound Manager&#39;&quot; turns up nothing useful. My<br/>&gt;MacPerl installation does have sound.pm, just no documentation.<br/>&gt;<br/>&gt;Does anyone know where to find the missing documentation?<br/><br/>I don&#39;t know why the Help menu doesn&#39;t show it (I&#39;ll look into it), but<br/>going to Shuck and the Go -&gt; Lookup ... menu item and entering &quot;Mac::Sound&quot;<br/>will give you the docmentation, which tells you two things:<br/><br/>1. The API is documented in Inside Macintosh, and you should go there for<br/>details<br/>2. The MacPerl interface to the Sound Manager is not documented.<br/><br/>So it wouldn&#39;t help much even if the menu item for it worked. :-)<br/><br/>However, if you select the View -&gt; Show Code Sections menu item, you can<br/>see the API, in the Perl and XS code. That will show you what functions<br/>are available. See Inside Macintosh for the sound functions you want, and<br/>how to use them.<br/><br/>You can start here:<br/><br/> http://developer.apple.com/techpubs/mac/Sound/Sound-2.html<br/><br/>Note also that in Carbon, you don&#39;t play sounds from files; Apple<br/>recommends instead to use the QuickTime API.<br/><br/>-- <br/>Chris Nandor pudge@pobox.com http://pudge.net/<br/>Open Source Development Network pudge@osdn.com http://osdn.com/<br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2002/11/msg84.html Sun, 10 Nov 2002 15:01:43 +0000 Sound Manager Toolbox docs? by Elliott Moreton Hi,<br/><br/>I&#39;d like to have a MacPerl 5.6.1b3 script play a sound file (not a<br/>resource, but a file; .wav, .aiff, or .raw) on a Power Book. <br/><br/>However, I can&#39;t find any documentation on the MacPerl Sound Manager<br/>Toolbox Module. When I go to the menu bar and choose Help : Macintosh<br/>Toolbox Manager : Sound Manager (which should bring up a man page in<br/>Shuck), I get &#39;Can&#39;t open that file, because a &quot;Directory or File not<br/>found&quot; error occurred&#39;. Other Toolbox man pages come up just fine. A<br/>Google search on &quot;MacPerl &#39;Sound Manager&#39;&quot; turns up nothing useful. My<br/>MacPerl installation does have sound.pm, just no documentation.<br/><br/>Does anyone know where to find the missing documentation?<br/><br/>Many thanks,<br/>Elliott Moreton<br/><br/><br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2002/11/msg83.html Sun, 10 Nov 2002 14:24:52 +0000 Re: [MacPerl-Toolbox] Help, I want to create folders... by Chris Nandor At 10:42 +0200 2002.09.02, Thomas Wegner wrote:<br/>&gt;At 10:48 Uhr -0500 01.09.2002, Greenblatt &amp; Seay wrote:<br/>&gt;<br/>&gt;[snip]<br/>&gt;<br/>&gt;&gt;Where can I find ChooseObjects.t? I installed MacPerl 5.6.1r1 using<br/>&gt;&gt;the wonderful web updater but according to Sherlock I don&#39;t have any<br/>&gt;&gt;&#39;.t&#39; files.<br/>&gt;&gt;<br/>&gt;<br/>&gt;It is distributed with the MacPerl sources. Sorry I didn&#39;t mention<br/>&gt;this. Chris, if you read this, shouldn&#39;t we distribute the test files<br/>&gt;with MacPerl 5.6.1r2? Since those files can also be seen as (small)<br/>&gt;examples, I think it would make sense (and as you see, there is<br/>&gt;public demand).<br/><br/>Yeah, I forgot them in r1. They&#39;ll reappear in r2.<br/><br/>-- <br/>Chris Nandor pudge@pobox.com http://pudge.net/<br/>Open Source Development Network pudge@osdn.com http://osdn.com/<br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2002/09/msg82.html Mon, 02 Sep 2002 04:05:13 +0000 Re: [MacPerl-Toolbox] Help, I want to create folders... by Thomas Wegner At 10:48 Uhr -0500 01.09.2002, Greenblatt &amp; Seay wrote:<br/><br/>[snip]<br/><br/>&gt;Where can I find ChooseObjects.t? I installed MacPerl 5.6.1r1 using <br/>&gt;the wonderful web updater but according to Sherlock I don&#39;t have any <br/>&gt;&#39;.t&#39; files.<br/>&gt;<br/><br/>It is distributed with the MacPerl sources. Sorry I didn&#39;t mention <br/>this. Chris, if you read this, shouldn&#39;t we distribute the test files <br/>with MacPerl 5.6.1r2? Since those files can also be seen as (small) <br/>examples, I think it would make sense (and as you see, there is <br/>public demand).<br/><br/>Regards,<br/><br/>Thomas.<br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2002/09/msg81.html Mon, 02 Sep 2002 01:51:51 +0000 Re: [MacPerl-Toolbox] Help, I want to create folders... by Alan Fry At 10:48 am -0500 01/09/02, Greenblatt &amp; Seay wrote:<br/>&gt;Thanks Thomas! This code will come in very handy.<br/>&gt;<br/>&gt;At 12:56 PM +0200 2002/08/30, Thomas Wegner wrote:<br/>&gt;&gt;&gt;#! perl -w<br/>&gt;&gt;use Mac::Navigation;<br/>&gt;&gt;<br/>&gt;&gt;$options = NavGetDefaultDialogOptions();<br/>&gt;&gt;$options-&gt;message(&quot;What&#39;s up, Doc?&quot;);<br/>&gt;&gt;$reply = NavChooseObject(&quot;&quot;, $options, undef, sub {1}) or die $^E;<br/>&gt;<br/>&gt;If I click on &quot;Cancel&quot; I get the error message &quot;# User canceled the <br/>&gt;query (OS error -128)&quot; and the program quits. I find it more useful <br/>&gt;to change the preceeding line to...<br/>&gt; $reply = NavChooseObject(&quot;&quot;, $options, undef, sub {1}) or $err = &quot;$^E\n\n&quot;;<br/>&gt;so that $err can be examined to see if it contains the word <br/>&gt;&quot;cancelled&quot; so the program can continue.<br/>&gt;<br/>&gt;&gt;for ($i = 0; $i++&lt;$reply-&gt;count; ) {<br/>&gt;&gt; print $reply-&gt;file($i), &quot;\n&quot;;<br/>&gt;&gt;}<br/>&gt;<br/>&gt;There is nothing returned in the first loop when &#39;$i&#39; is &#39;0&#39;. It&#39;s <br/>&gt;neat that the user can shift click to select multiple files or use <br/>&gt;the &#39;Select All&#39; menu item to select all files in the dialog.<br/>&gt;<br/>&gt;&gt;(copied from the ChooseObjects.t test/example script)<br/>&gt;<br/>&gt;Where can I find ChooseObjects.t? I installed MacPerl 5.6.1r1 using <br/>&gt;the wonderful web updater but according to Sherlock I don&#39;t have any <br/>&gt;&#39;.t&#39; files.<br/><br/>Somehow I missed the beginning of this thread, but if the question is <br/>how to select existing or create new folders, the script below might <br/>be appropriate. It behaves sensibly when the &#39;cancel&#39; button is hit.<br/><br/>In passing note the line &quot;$options-&gt;location($pt);&quot; which has the <br/>side effect of making the dialog movable, which &quot;Inside Macintosh&quot; <br/>strongly advises one to do.<br/><br/>Alan Fry<br/><br/>____________<br/><br/><br/>#!perl -w<br/>#18 Aug 2000 ajf@afco.demon.co.uk<br/><br/>use Mac::Navigation;<br/>use Mac::Files;<br/>use Mac::QuickDraw;<br/>use strict;<br/><br/>my $pt = new Point(56, 74);<br/><br/>my $dir = FindFolder(kOnSystemDisk, kDesktopFolderType);<br/>my $options = NavGetDefaultDialogOptions();<br/>$options-&gt;location($pt);<br/><br/>$options-&gt;message(&#39;Choose a folder&#39;);<br/>$options-&gt;windowTitle(&quot;FolderFinder&quot;);<br/><br/>my $reply = NavChooseFolder( $dir, $options, sub{1});<br/><br/>if (defined $reply) {<br/> for (1..$reply-&gt;count) { print $reply-&gt;file($_), &quot;\n&quot; }<br/>}<br/><br/>NavDisposeReply $reply if defined $reply;<br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2002/09/msg80.html Sun, 01 Sep 2002 11:51:49 +0000 Re: [MacPerl-Toolbox] Help, I want to create folders... by Greenblatt & Seay Thanks Thomas! This code will come in very handy.<br/><br/>At 12:56 PM +0200 2002/08/30, Thomas Wegner wrote:<br/>&gt;&gt;#! perl -w<br/>&gt;use Mac::Navigation;<br/>&gt;<br/>&gt;$options = NavGetDefaultDialogOptions();<br/>&gt;$options-&gt;message(&quot;What&#39;s up, Doc?&quot;);<br/>&gt;$reply = NavChooseObject(&quot;&quot;, $options, undef, sub {1}) or die $^E;<br/><br/>If I click on &quot;Cancel&quot; I get the error message &quot;# User canceled the <br/>query (OS error -128)&quot; and the program quits. I find it more useful <br/>to change the preceeding line to...<br/> $reply = NavChooseObject(&quot;&quot;, $options, undef, sub {1}) or $err = &quot;$^E\n\n&quot;;<br/>so that $err can be examined to see if it contains the word <br/>&quot;cancelled&quot; so the program can continue.<br/><br/>&gt;for ($i = 0; $i++&lt;$reply-&gt;count; ) {<br/>&gt; print $reply-&gt;file($i), &quot;\n&quot;;<br/>&gt;}<br/><br/>There is nothing returned in the first loop when &#39;$i&#39; is &#39;0&#39;. It&#39;s <br/>neat that the user can shift click to select multiple files or use <br/>the &#39;Select All&#39; menu item to select all files in the dialog.<br/><br/>&gt;(copied from the ChooseObjects.t test/example script)<br/><br/>Where can I find ChooseObjects.t? I installed MacPerl 5.6.1r1 using <br/>the wonderful web updater but according to Sherlock I don&#39;t have any <br/>&#39;.t&#39; files.<br/><br/><br/>David Seay<br/>http://www.mastercall.com/g-s/<br/><br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2002/09/msg79.html Sun, 01 Sep 2002 08:47:35 +0000 Re: [MacPerl-Toolbox] Help, I want to create folders... by Thomas Wegner At 21:44 Uhr +0200 29.08.2002, Thomas De Groote wrote:<br/>&gt;Hey,<br/>&gt;<br/>&gt;I have this small project I promissed to finish this evening, cause I<br/>&gt;thought I knew enough Perl and Shuck would help me...<br/>&gt;<br/>&gt;Problem is I never used the toolbox before and now I can&#39;t find the dialog<br/>&gt;calls to make a &#39;select destination folder&#39; dialog and get its results. I<br/>&gt;can do get files (StandardGetFile) and when a user clicks cancel in that,<br/>&gt;it does return the last folder, but that is not a real nice way to work,<br/>&gt;is it ?<br/>&gt;<br/>&gt;Could anyone please tell me how to do a &#39;select folder&#39; thingy ? I would<br/>&gt;be very happy and could finally get asleep :)<br/>&gt;<br/>&gt;Thomas<br/><br/><br/>Good morning :-).<br/><br/><br/>In MacPerl 5.2.0.r4 you can use the GetFolder function,<br/><br/># Syntax<br/># $foldername = &amp;GetFolder($prompt [, $default]);<br/><br/>which can be found in the old library file &quot;StandardFile.pl&quot;. In <br/>MacPerl 5.6.1r1 there is currently no possibility to use StandardFile <br/>to select a folder. However, this will be changed in MacPerl 5.6.1r2.<br/><br/>In both MacPerl versions you can use the new Navigation Services, <br/>which is a bit more complicated. Recently, I have posted this little <br/>script to the MacPerl list:<br/><br/><br/><br/>#! perl -w<br/>use Mac::Navigation;<br/><br/>$options = NavGetDefaultDialogOptions();<br/>$options-&gt;message(&quot;What&#39;s up, Doc?&quot;);<br/>$reply = NavChooseObject(&quot;&quot;, $options, undef, sub {1}) or die $^E;<br/><br/>for ($i = 0; $i++&lt;$reply-&gt;count; ) {<br/> print $reply-&gt;file($i), &quot;\n&quot;;<br/>}<br/><br/>__END__<br/><br/>(copied from the ChooseObjects.t test/example script)<br/><br/>It should do what you want.<br/><br/><br/>HTH,<br/><br/>Thomas.<br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2002/08/msg78.html Fri, 30 Aug 2002 04:39:05 +0000 Help, I want to create folders... by Thomas De Groote Hey,<br/><br/>I have this small project I promissed to finish this evening, cause I<br/>thought I knew enough Perl and Shuck would help me...<br/><br/>Problem is I never used the toolbox before and now I can&#39;t find the dialog<br/>calls to make a &#39;select destination folder&#39; dialog and get its results. I<br/>can do get files (StandardGetFile) and when a user clicks cancel in that,<br/>it does return the last folder, but that is not a real nice way to work,<br/>is it ?<br/><br/>Could anyone please tell me how to do a &#39;select folder&#39; thingy ? I would<br/>be very happy and could finally get asleep :)<br/><br/>Thomas<br/><br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2002/08/msg77.html Thu, 29 Aug 2002 12:45:26 +0000 Rule_90 by Alan Fry I have been dipping into a fat and fascinating book, &quot;The New <br/>Science&quot; by Stephen Wolfram who took a PhD in Physics at Caltech in <br/>1979. His theses concern the complex consequences of simple rules.<br/><br/>This is the first example in the book, a fractal-like pattern in <br/>which each pixel is set if the pixel in the row above has one <br/>neighbour set (Rule 90); like this:<br/><br/> 111 110 101 100 011 010 001 000<br/> 0 1 0 1 1 0 1 0<br/><br/>It lends itself so nicely to a MacPerl window I hope it might be of <br/>some interest.<br/><br/>Alan Fry<br/><br/><br/>#------------------------------------------------------------------------------<br/><br/>#!perl -w<br/><br/>use Mac::Windows;<br/>use Mac::QuickDraw;<br/>use Mac::Events;<br/>use strict;<br/>use vars qw($v $OK);<br/><br/>#----------------------------------- window -----------------------------------<br/><br/>$v-&gt;{frame} = OffsetRect(new Rect(0, 0,1024, 512), 6, 62);<br/>$v-&gt;{win} = MacColorWindow-&gt;new($v-&gt;{frame}, &quot;Rule_90&quot;, 1, 4, 1);<br/>SetPort $v-&gt;{win}-&gt;window;<br/>RGBBackColor(new RGBColor(52224, 65535, 65535));<br/>$v-&gt;{col} = new RGBColor(65535, 0, 0);<br/>$v-&gt;{win}-&gt;sethook(&#39;drawgrowicon&#39;, sub { 1 });<br/>$v-&gt;{win}-&gt;sethook(&#39;goaway&#39;, sub {TrackGoAway($_[0]-&gt;{port}, $_[1]); $OK = 1});<br/>$v-&gt;{win}-&gt;sethook(&#39;redraw&#39;, \&amp;myDraw );<br/><br/>#------------------------------ Wait Next Event -------------------------------<br/><br/>while ($v-&gt;{win}-&gt;window and !$OK) { WaitNextEvent };<br/><br/>#---------------------------------- cleanup -----------------------------------<br/><br/>$v-&gt;{win}-&gt;dispose;<br/><br/>#-------------------------------- subroutines ---------------------------------<br/><br/>sub myDraw {<br/> my (@new, @old);<br/> my ($i, $j);<br/><br/> @old = (0) x 1024;<br/> $old[512] = 1;<br/> SetCPixel(512, 0, $v-&gt;{col});<br/><br/> @new = (0) x 1024;<br/><br/> for $i (1..511) {<br/> for $j (1..1022) {<br/> $new[$j] = ($old[$j-1] + $old[$j+1]) % 2;<br/> }<br/> @old = @new;<br/> for (0..1024) {<br/> if ($old[$_]) { SetCPixel($_, $i, $v-&gt;{col}) }<br/> }<br/> }<br/>}<br/><br/>#------------------------------------------------------------------------------<br/><br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2002/08/msg76.html Thu, 29 Aug 2002 03:11:59 +0000 Re: [MacPerl-Toolbox] Mac::OSA::Simple and Applescript properties by Chris Nandor At 18:48 -0400 2002.07.18, Chris Nandor wrote:<br/>&gt;Well, I changed line 178 from:<br/>&gt; $self-&gt;{ID} = OSACompile($self-&gt;{COMP}, $self-&gt;{SCRIPT}, 0) or<br/>&gt;<br/>&gt;to:<br/>&gt; $self-&gt;{ID} = OSACompile($self-&gt;{COMP}, $self-&gt;{SCRIPT},<br/>&gt;kOSAModeCompileIntoContext) or<br/>&gt;<br/>&gt;And it gets the behavior you expect. I am not entirely sure this is the<br/>&gt;Right Thing, although it certainly seems to be; if it is the right thing, I<br/>&gt;wonder if it should be an option.<br/><br/>I&#39;ve read up on what I could find about this in IM:IAC, and it seems that<br/>this is the right thing. I couldn&#39;t really find any downside to this<br/>change; if someone objects, I can add back the old behavior, maybe with a<br/>switch, or separate function, or something.<br/><br/>-- <br/>Chris Nandor pudge@pobox.com http://pudge.net/<br/>Open Source Development Network pudge@osdn.com http://osdn.com/<br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2002/07/msg75.html Tue, 30 Jul 2002 20:26:23 +0000 Re: [MacPerl-Toolbox] Mac::OSA::Simple and Applescript properties by Chris Nandor At 23:48 +0200 2002.07.18, Bart Lateur wrote:<br/>&gt;I&#39;d think this isn&#39;t quite the appropriate behaviour... Is something<br/>&gt;wrong related to some contextid (a phrase I picked up from the Mac::OSA<br/>&gt;docs )?<br/>&gt;<br/>&gt; #! perl -wl<br/>&gt; use Mac::OSA::Simple;<br/>&gt; my $script = compile_applescript(&lt;&lt;&#39;SCRIPT&#39;) or die $^E;<br/>&gt; property foo: 20<br/>&gt; set foo to foo + 1<br/>&gt; SCRIPT<br/>&gt; print $script-&gt;execute;<br/>&gt; print $script-&gt;execute;<br/>&gt; print $script-&gt;execute;<br/>&gt;<br/>&gt;This prints:<br/>&gt;<br/>&gt; 21<br/>&gt; 21<br/>&gt; 21<br/>&gt;<br/>&gt;I would have expected<br/>&gt;<br/>&gt; 21<br/>&gt; 22<br/>&gt; 23<br/>&gt;<br/>&gt;i.e. the context for the property should be retained between<br/>&gt;invocations.<br/>&gt;<br/>&gt;No?<br/><br/>Well, I changed line 178 from:<br/> $self-&gt;{ID} = OSACompile($self-&gt;{COMP}, $self-&gt;{SCRIPT}, 0) or<br/><br/>to:<br/> $self-&gt;{ID} = OSACompile($self-&gt;{COMP}, $self-&gt;{SCRIPT},<br/>kOSAModeCompileIntoContext) or<br/><br/>And it gets the behavior you expect. I am not entirely sure this is the<br/>Right Thing, although it certainly seems to be; if it is the right thing, I<br/>wonder if it should be an option.<br/><br/>Thoughts?<br/><br/>Note that Mac::OSA::Simple is by far the least-used module, judging from<br/>user feedback, that I&#39;ve released, so it&#39;s surely got some room for<br/>improvement. :-)<br/><br/>If I had the time, I would read up on the relevant chapters of Inside<br/>Macintosh: Interapplication Communication, but at present, I do not have<br/>the time, so feedback is more than welcome.<br/><br/>FWIW, I did this after the above change:<br/><br/> #!perl -wl<br/> use Mac::OSA::Simple;<br/> my $file = &quot;Bourque:Desktop Folder:osatest&quot;;<br/> my $script;<br/><br/> if (-e $file) {<br/> $script = load_osa_script($file, 1);<br/> } else {<br/> $script = compile_applescript(&lt;&lt;&#39;SCRIPT&#39;) or die $^E;<br/> property foo: 20<br/> set foo to foo + 1<br/> SCRIPT<br/> }<br/><br/> print $script-&gt;execute;<br/> print $script-&gt;execute;<br/> print $script-&gt;execute;<br/> $script-&gt;save($file); # save with context<br/><br/>Each time it runs, it executes three times and saves the context at the<br/>end, so when it is run three times:<br/><br/> 21<br/> 22<br/> 23<br/> 24<br/> 25<br/> 26<br/> 27<br/> 28<br/> 29<br/><br/>-- <br/>Chris Nandor pudge@pobox.com http://pudge.net/<br/>Open Source Development Network pudge@osdn.com http://osdn.com/<br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2002/07/msg74.html Thu, 18 Jul 2002 15:48:42 +0000 Mac::OSA::Simple and Applescript properties by Bart Lateur [I don&#39;t really know if I should send this to Macperl-modules or to<br/>Macperl-toolbox. Since Mac::OSa::Simple is a Toolbox module... so there!<br/>:-)]<br/><br/>I&#39;d think this isn&#39;t quite the appropriate behaviour... Is something<br/>wrong related to some contextid (a phrase I picked up from the Mac::OSA<br/>docs )?<br/><br/> #! perl -wl<br/> use Mac::OSA::Simple;<br/> my $script = compile_applescript(&lt;&lt;&#39;SCRIPT&#39;) or die $^E;<br/> property foo: 20<br/> set foo to foo + 1<br/> SCRIPT<br/> print $script-&gt;execute;<br/> print $script-&gt;execute;<br/> print $script-&gt;execute;<br/><br/>This prints:<br/><br/> 21<br/> 21<br/> 21<br/><br/>I would have expected<br/><br/> 21<br/> 22<br/> 23<br/><br/>i.e. the context for the property should be retained between<br/>invocations.<br/><br/>No?<br/><br/>-- <br/> Bart.<br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2002/07/msg73.html Thu, 18 Jul 2002 14:49:29 +0000 MacPerl's spin-cursor (was The Camel and his counfounded Ball) by Alan Fry At 11:17 am +0100 12/06/02, I wrote to MacPerl-Toolbox:<br/>&gt;The following script demonstrates the phenomenon:<br/>&gt;<br/>&gt; #!perl<br/>&gt; # exit via Cmd+period<br/>&gt;<br/>&gt; use Mac::Events;<br/>&gt; use Mac::Events qw(@Event);<br/>&gt;<br/>&gt; $Event[mouseDown] = sub { while (WaitMouseUp()) {} };<br/>&gt;<br/>&gt; WaitNextEvent while 1;<br/>&gt;<br/>&gt;<br/>&gt;About two seconds after mouse-down MacPerl switches to the <br/>&gt;spin-cursor and remains that way until mouse-up.<br/>&gt;<br/>&gt;IMO this behaviour is highly undesirable since it spoils any <br/>&gt;application involving a &#39;WaitMouseUp&#39; event, such as <br/>&gt;button-tracking, auto-scrolling and similar regular GUI functions.<br/><br/>The attached patch appears to provide a solution. So far as I can <br/>determine the normal functions of MacPerl are unaffected by this <br/>change.<br/><br/>However I am a long long way from fully understanding the inner <br/>workings of MacPerl in relation to the spin cursor, so the proposal <br/>needs the scrutiny of wiser heads than mine -- to say the least.<br/><br/>Alan Fry<br/><br/>-----------<br/><br/>--- <br/>Millgate:Programming:BuildMacPerl:macperl_src:macperl:MPMain.c.orig <br/> Mon Jan 7 14:36:34 2002<br/>+++ Millgate:Programming:BuildMacPerl:macperl_src:macperl:MPMain.c <br/> Tue Jun 11 16:54:12 2002<br/>@@ -1182,6 +1182,7 @@<br/> long now;<br/> EventRecord myEvent;<br/> Point mouse;<br/>+ char up;<br/><br/> if (!gSacrificialGoat) /* Memory trouble */<br/> if (gRunningPerl) /* This <br/>script has gone too far */<br/>@@ -1191,6 +1192,7 @@<br/> exit(0); /* Save our <br/>sorry ass. Shouldn&#39;t happen */<br/><br/> now = LMGetTicks();<br/>+ up = LMGetMouseButtonState();<br/> if (spinning = busy) {<br/> if (now - lastNonBusy &lt; (gInBackground ? <br/>BACK_BUSY_WAIT : FRONT_BUSY_WAIT))<br/> spinning = false;<br/>@@ -1201,6 +1203,9 @@<br/> events = activMask | updateMask | highLevelEventMask | osMask;<br/> spinning = false;<br/> }<br/>+<br/>+ if (!up)<br/>+ spinning = false;<br/><br/> MaintainMenuBar();<br/><br/>-------------<br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2002/06/msg72.html Thu, 13 Jun 2002 08:26:54 +0000 Re: [MacPerl-Toolbox] The Camel and his confounded Ball by Alan Fry At 11:10 am -0400 12/06/02, Chris Nandor wrote:<br/>&gt;At 17:08 +0200 2002.06.12, Bart Lateur wrote:<br/>&gt;&gt;On Wed, 12 Jun 2002 16:01:32 +0100, Alan Fry wrote:<br/>&gt;&gt;<br/>&gt;&gt;&gt;Any ideas on how to tackle this?<br/>&gt;&gt;<br/>&gt;&gt;MacPerl should have an access method to override &quot;spinning&quot; from the<br/>&gt;&gt;value calculated here. That probably will mean XS, yes. For example:<br/>&gt;&gt;<br/>&gt;&gt; value effect<br/>&gt;&gt; undef default (as now)<br/>&gt;&gt; true override: on<br/>&gt;&gt; (0, &quot;&quot;) override: off<br/>&gt;<br/>&gt;Yes, this is sorta what I had in mind (cf. Mac::err, also XS, which sets a<br/>&gt;precedent for this kind of thing).<br/><br/><br/>I see what you mean, but you are both way ahead of me. I haven&#39;t a <br/>clue at the moment how to override the switch to the spin cursor <br/>under any circumstances.<br/><br/>Alan Fry<br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2002/06/msg71.html Wed, 12 Jun 2002 09:48:09 +0000 Re: [MacPerl-Toolbox] The Camel and his confounded Ball by Chris Nandor At 17:08 +0200 2002.06.12, Bart Lateur wrote:<br/>&gt;On Wed, 12 Jun 2002 16:01:32 +0100, Alan Fry wrote:<br/>&gt;<br/>&gt;&gt;Any ideas on how to tackle this?<br/>&gt;<br/>&gt;MacPerl should have an access method to override &quot;spinning&quot; from the<br/>&gt;value calculated here. That probably will mean XS, yes. For example:<br/>&gt;<br/>&gt; value effect<br/>&gt; undef default (as now)<br/>&gt; true override: on<br/>&gt; (0, &quot;&quot;) override: off<br/><br/>Yes, this is sorta what I had in mind (cf. Mac::err, also XS, which sets a<br/>precedent for this kind of thing).<br/><br/>-- <br/>Chris Nandor pudge@pobox.com http://pudge.net/<br/>Open Source Development Network pudge@osdn.com http://osdn.com/<br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2002/06/msg70.html Wed, 12 Jun 2002 08:12:45 +0000 Re: [MacPerl-Toolbox] The Camel and his confounded Ball by Chris Nandor At 16:01 +0100 2002.06.12, Alan Fry wrote:<br/>&gt;Any ideas on how to tackle this?<br/><br/>Two, offhand.<br/><br/>One, a Perl-accessible flag to toggle the behavior.<br/><br/>Two, a way to override the behavior with another cursor.<br/><br/>I am not sure if either would be appropriate, thinking about this only brielfy.<br/><br/>-- <br/>Chris Nandor pudge@pobox.com http://pudge.net/<br/>Open Source Development Network pudge@osdn.com http://osdn.com/<br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2002/06/msg69.html Wed, 12 Jun 2002 08:10:12 +0000 Re: [MacPerl-Toolbox] The Camel and his confounded Ball by Bart Lateur On Wed, 12 Jun 2002 16:01:32 +0100, Alan Fry wrote:<br/><br/>&gt;Any ideas on how to tackle this?<br/><br/>MacPerl should have an access method to override &quot;spinning&quot; from the<br/>value calculated here. That probably will mean XS, yes. For example: <br/> <br/> value effect<br/> undef default (as now)<br/> true override: on<br/> (0, &quot;&quot;) override: off<br/><br/>-- <br/> Bart.<br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2002/06/msg68.html Wed, 12 Jun 2002 08:09:40 +0000 Re: [MacPerl-Toolbox] The Camel and his confounded Ball by Alan Fry At 6:59 am -0400 12/06/02, Chris Nandor wrote:<br/>&gt;Sure.<br/>&gt;<br/>&gt;I have no idea offhand what to do about it, so anyone else with an idea is<br/>&gt;more than welcome to submit a patch. :)<br/><br/>I think -- but am far from sure -- that it all happens is in this <br/>part of the MainEvent loop in MPMain.c<br/><br/> ......<br/><br/> now = LMGetTicks();<br/> if (spinning = busy) {<br/> if (now - lastNonBusy &lt; (<br/> gInBackground ? BACK_BUSY_WAIT : FRONT_BUSY_WAIT))<br/> spinning = false;<br/> } else<br/> lastNonBusy = now;<br/><br/> if (gMacPerl_InModalDialog) {<br/> events = activMask | updateMask | highLevelEventMask | osMask;<br/> spinning = false;<br/> }<br/><br/> MaintainMenuBar();<br/><br/> if (spinning) {<br/> if (now-lastBusySpin &lt; 3)<br/> return;<br/><br/> lastBusySpin = now;<br/> RotateCursor(32);<br/><br/> if (now - lastWNE &lt; (<br/> gInBackground ? BACK_FREQUENCY : FRONT_FREQUENCY))<br/> return;<br/> } else<br/> MaintainCursor();<br/><br/> lastWNE = now;<br/> gGotEof = nil;<br/><br/> ......<br/><br/>&#39;FRONT_BUSY_WAIT&#39; is defined as 120 (presumably &#39;ticks&#39;?) which <br/>stacks up with the 2 second delay before the spin-cursor kicks in.<br/><br/>Any ideas on how to tackle this?<br/><br/>Alan Fry<br/> http://www.nntp.perl.org/group/perl.macperl.toolbox/2002/06/msg67.html Wed, 12 Jun 2002 08:02:24 +0000