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

Re: [MacPerl] Script runs, but runtime version stops, missing a lib



At 04.52 98.01.13, Toni Zollikofer wrote:
>I have a script (called "Eu_Net") debugged, that runs now without errors
>within the MacPerl application.
>When I save it as a "Runtime Version" and try to run it, it stops with the
>following error message:
>-- Message start
>
># Can't locate StandardFile.pl in @INC.
>File 'Toni Zollikofer HD1:Desktop Folder:Eu_Net'; Line 76
>
>-- Message end
>
>The file "StandardFile.pl" is in the lib.
>I have installed so far only the MacPerl application (the absolut latest
>one, 5.1.8r4 from 5 Jan 98), i.e. no bigappl, no bigtool etc.
>My machine is a PowerMac running OS8.
>
>Do I need to use an INCLUDE statement in my script?
>
>Many thanks for any hints how to solve this.

Runtimes do not, by default, have access to libraries and modules that you
include.  If you make the script below into a droplet and drop your saved
runtime on to it, it should work.  Or, by hand, you can save the text of
each module/library in the TEXT resource of your runtime, and give it
relative name of that module/library: i.e., StandardFile.pl would just be
StandardFile.pl, but Mac::StandardFile would be Mac:StandardFile.pm.

Also, Mac::StandardFile is the better way to do StandardFile stuff for the
most part.  It is documented in the Toolbox Modules chapter of the book,
draft chapter available online (URL below).  The problem then will be that
Mac::StandardFile requires a shared library under PPC and CFM-68K, which
cannot be included in the runtime.

A way around this is to install a 68K-only version of the BigMacPerl
application (I just install the FAT version of it and then use a program
called StripPPC to strip out the PPC code).  If saved with with BigMacPerl
68K, the "shared libraries" are linked statically into the code and the app
doesn't have to go anywhere to get them.  This will be the case with the
FAT version of BigMacPerl too, but with the FAT version it will look for
the shared libraries on a PPC but not on a 68K.  So the only downside is
that you will have to run in 68K emulation on a PPC machine.

Hope this is not too confusing.  Droplet follows.  One problem with the
droplet also is that it does not include autoloaded files, but maybe
someone else can figure that part out.

#"ExtractModules.dp"
#=========================================
#!perl

use Mac::Resources;
use Mac::Memory;

#ARGV now in scalar context (thanks to Bart and Chris)
$res= OpenResFile($ARGV[0]) || die $^E;

#first 'TEXT' resource is source code:
$sourceCodeRes= Get1IndResource('TEXT', 1);
$sourceCodeText= $sourceCodeRes-> get();

#clear the hash:
undef(%INC);

#suppress warnings about redefining subroutines
#by 'eval(use...)':
local $^W = 0;

#angle operator doesn't work here(?):
@sourceCodeText= split /\n/, $sourceCodeText;
for (@sourceCodeText){
        if(/^use.*;/){
                eval($_); #read the %INC
        }
}

$id= 5000;
foreach $libFileName(keys %INC) {
        $aText= "";

        open(libFile, $INC{$libFileName}) or die $^E;
        while(<libFile>){
                $aText.= $_;
        }
        $codeHand= new Handle($aText);

        #UNIX-> Mac Folder
        $libFileName=~ s/\//:/g;
        AddResource($codeHand, 'TEXT', $id, $libFileName) or die $^E;
        WriteResource($codeHand) or die $^E;;
        ReleaseResource($codeHand) or die $^E;;
        $codeHand-> dispose;
        $id++;
        print "Copied module ".$libFileName." into resource fork.\n";
}
CloseResFile($res);
sleep(3);
&MacPerl'Quit(3);

__END__

--
Chris Nandor               pudge@pobox.com           http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])
#==                    MacPerl: Power and Ease                     ==#
#==    Publishing Date: Early 1998. http://www.ptf.com/macperl/    ==#



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch