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

Re: [MacPerl] & Usage and Misc. ?'s



At 12.36 -0500 1998.11.02, Mark Yannuzzi wrote:
>1) The "StandardFile.pl" library has a very useful function called
>"GetFolder" that lets a user select a directory instead of a file.  I
>understand that modules have replaced libraries in version 5, but I
>cannot find a straight forward equivalent in any of the packages.

Right.  There isn't one, unfortunately.


>From
>what I have pieced together, the Mac::StandardFile package has a function:
>
>  CustomGetFile(FILEFILTER, TYPELIST, DLGID, WHERE)
>
>that will perform the task, IF you know what data types/parameters need
>to be fed to it.  I perused the Inside Macintosh on-line "Files" volume
>and found some (complicated, given that I am an Inside Macintosh virgin,
>and do not have a lot of extra time to spend deciphering them just now)
>examples in Pascal on how to do this, but I could not find an obvious
>correspondence between the MacPerl parameter list for CustomGetFile, and
>that shown in the examples in Inside Macintosh. Additionally, I could not
>find a defining function template for the function. Does anyone know what
>types "FILEFILTER, TYPELIST, DLGID, WHERE" are?

I've never played with that (that I can remember), though I would try
putting in 0 or '' values.  :)


>2) I noticed that once I included one or more "use" statements, that I
>had to define all my variables as private using the "my()" command, in
>order to not have to include "main::" when using them.  I this "normal"?

use strict does that, and yes, it is normal and good.  If you need a global
variable, you can define it with use vars:

  use strict;
  use vars qw($some $vars @go %here);


>The following is intended as constructive feedback for the authors of
>"MacPerl Power and Ease", Vicki Brown and Chris Nandor, in case there
>"listening":
>
>3) I noticed the use of the "&" character in a non-logical operator
>context, in an example on pg. 186.  I gather that it has something to do
>with calling subroutines, but the construct is not introduced anywhere in
>the text, it would be helpful if a sentence or two were included about
>this usage, and how it differs from simply calling a subroutine without
>it.

Hm.  Yes, if & is not in there, it probably should be.  Although, I should
note that MacPerl: Power and Ease is a supplement to, not a replacement of,
the Perl documentation (found in the MacPerl Help menu, or in the
Programming Perl bok from O'Reilly), and in the "perlsub" manpage
("Subroutines" under Help), & is covered there.


>I have discovered through trial and error that the following two
>statements are equivalent, on the surface:
>
>  &StandardFile'GetFolder() & StandardFile::GetFolder()

The only differences here are with ' and ::, which are the exact same
thing, but the former is deprecated.  Don't use it (unless you want to :).
This is mentioned in a footnote on p. 161, where :: is introduced.


>4) pg. 187 has an example containing a line that appears to be a shortcut:
>
>$answer = (MacPerl::Answer('Erase existing file?', 'No', 'OK')) if
>($file->sfReplacing());
>
>that suggests that the "if" statement is executed first, and if TRUE, the
>statement preceding it is executed (bizarre), otherwise, proceed to the
>next line.

Yes.  Not so bizarre to me, though.


>Perhaps you could include a brief discussion of this along
>with your other shortcut examples (the ?: construct, etc.).

Good idea.

Thanks for the feedback,

--
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 mac-perl-request@iis.ee.ethz.ch