MacPerl - Built-in Macintosh specific routines.
$phone = MacPerl::Ask("Enter your phone number:"); MacPerl::Answer("Nunc et in hora mortis nostrae", "Amen"); $color = MacPerl::Pick("What's your favorite color baby ?", "Red", "Green", "Gold"); MacPerl::SetFileInfo("MPS ", "TEXT", yin, yang); MacPerl::GetFileInfo(yin); MacPerl::Quit(kMacPerlAlwaysQuit);
Presents to the user a dialog with 1, 2, or 3 buttons.
MacPerl::Answer("Nunc et in hora mortis nostrae", "Amen");
always returns 0.
is equivalent to
MacPerl'Answer("I refuse", "OK");
MacPerl::Answer("Delete hard disk ?", "OK", "Cancel");
returns 1 for OK, 0 for Cancel
MacPerl::Answer("Overwrite existig file", "Overwrite", "Skip", "Cancel");
returns 2 for Overwrite, 1 for Skip, 0 for Cancel
Asks the user for a string. A default value may be given. Returns undef if the dialog is cancelled.
$phone = MacPerl::Ask("Enter your phone number:"); $name = MacPerl::Ask("Enter your first name", "Bruce");
Useful for Australian database applications
Asks the user to pick a choice from a list. VALUES is a list of choices. Returns undef if the dialog is cancelled.
$color = MacPerl::Pick("What's your favorite color baby ?", "Red", "Green", "Gold");
Changes the file types and creators of the file(s).
MacPerl::SetFileInfo("MPS ", "TEXT", yin, yang);
Turn yin and yang into MPW text files
In scalar context, returns the file type. In array context, returns (creator,type).
Returns "TEXT" or ("MPS ", "TEXT").
Execute an AppleScript script. Returns the text of the script result. Script error strings are returned in
my $text = MacPerl::DoAppleScript(<<END_SCRIPT) or die $@; tell application "BBEdit" make new Window copy "Inserting text the hard way." to character 1 of front Window get (characters 1 through 9 of front Window) as text end tell END_SCRIPT
Note: calling DoAppleScript to tell MacPerl to do something via AppleScript may yield unpredictable results, especially when waiting on MacPerl to reply, such as when stringing multiple events together, or expecting data to be returned. Try wrapping the "tell" block in "ignoring application responses" / "end ignoring" if necessary.
Reply to current DoScript request. Useful if you are calling Perl scripts from other applications.
Mac OS only.
If LEVEL is 0, don't quit after ending the script. If 1, quit if running under a runtime version, if 2, always quit. If LEVEL is 3, quit if this was the first script to be run since starting MacPerl.
Mac OS only.
Load XCMD and XFCN extensions contained in file LIBFILE, which is searched along the same path as it would be for a require. The extensions are made accessible in the current package, unless they containing an explicit package name.
Mac OS only.
When called from the tool, manipulate various information of files. To get the command constants, it's convenient to require "FAccess.ph".
Manipulate tabulator setting (in spaces per tab).
Manipulate font and size information. Both font names and font numbers are accepted for F_SFONTINFO; F_GFONTINFO returns a font name in an array context, a font number in a scalar context.
Manipulate the MPW selection of a file.
Manipulate the window position.
This command encodes a path name into an encoding (volume #, directory #, File name) which is guaranteed to be unique for every file. Don't store this encoding between runs of MacPerl!
The inverse of MacPerl::MakeFSSpec(): turn an encoding into a path name.
In scalar context, return the FSSPEC of the startup volume. In list context, return FSSPECs of all volumes.