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

Re: [MacPerl] Droplet to make CGI?



Per Chris Nador:
>At 09.29 -0400 1998.08.01, Kevin van Haaren wrote:
>>Does anyone have a droplet already written to make a macperl text file into
>>a cgi type file?
>
>Well, an easy way to go about it would be to make a dummy CGI program, and
>then have a MacPerl droplet take the contents of the dropped file(s), make
>a copy of the dummy CGI, rename it filename.(a)cgi, and replace the TEXT
>resource of the new CGI with the text of the dropped file.

An Applescript Droplet like this would do the trick.  It doesn't do any 
renaming, isn't quite set up to handle multiple items and doesn't 
do any error handling, but you get the gist of it.  

It uses MacPerl to set the Type/Creator of the resultant file and 
to set its BNDL and Custom Icon bits after MacPerl saves the file as 
a CGI droplet.  On my systems at least, MacPerl didn't set these when 
"Save as... CGI" was called using the relevant apple event.  YMMV.

-Charles Albrecht 
 <albrecht@gate.net>

=-=-=-=-=

on run
  display dialog "Drop a script on me." buttons {"OK"} default button "OK"
end run

on open theItem
  Process(theItem)
end open

on Process(theItem)
  tell application "MacPerl"
   activate
   -- Assume no windows are already open	
   Open {theItem}
   Save document 1 in file {theItem} as Çconstant svasWWW½È
   -- That's <<constant svas....>> with W, W, W, Omega (opt-z)

   -- When called by AppleEvents, MacPerl doesn't seem to set the type & creator
   -- Nor does it set the Custom Icon or BNDL bit

   Close document 1

   -- Have MacPerl set the Type and Creator & the Custom Icon/BNDL bits
   set TheScript to "#!perl -w
     use Mac::Files; 
     my($file, $fileCat, $fileInfo); 
     $file ='" & {theItem} & "'; 
		
     MacPerl::SetFileInfo('MrPL', 'APPL', $file); 
		
     $fileCat = FSpGetCatInfo($file); 
     $fileInfo = $fileCat->ioFlFndrInfo(); 
		
     $fileInfo->fdFlags($fileInfo->fdFlags() | (2**10 + 2**13)); 
     $fileCat->ioFlFndrInfo($fileInfo); 
		
     FSpSetCatInfo($file, $fileCat); 
     __END__
   "
		
   Do Script TheScript with extract
		
   end tell
end Process

=-=-=-=-=



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