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

[MacPerl] MPW crash with perl tool and MacPerl::DoAppleScript



     Not sure if the culprit here is MPW or the perl tool or some other 
factor, but the following code (which executes flawlessly when run from 
the MacPerl app) causes MPW to crash when run normally... in debug mode 
in MPW it works fine... hmmmmm...

     I have been using this bit for some time in droplets and scripts run 
from Alpha thru the app, but when I use it in a script that was set up to 
be run from MPW (needs several command line arguments, so not suited to 
MacPerl app without major modification and thus violation of my code of 
ethical laziness  ;), it invariably crashes MPW, usually on the first 
run, always on the second if it makes it through the first... and the 
crash is non-recoverable... ea or es pops me back to MacsBug, and a 
second ea/es freezes me and forces me to cmd-ctl-pwr out...

# _BEGIN CODE_
sub dateFromAS {
 my ( $d, $ld );
	( $d ) = @_;
	$ld = &MacPerl::DoAppleScript( <<END_SCRIPT );

set a to date "$d"
return (date string for a in $opt format)

END_SCRIPT

	$ld =~ s!["]!!g;
	return $ld;
}
# _END CODE_

     To short-circuit the waste of bandwidth on unhelpful replies... no 
"tell application so-and-so" statement is needed for this fragment to 
work... the problem is not to be found in the AS syntax... to test this, 
pass the sub any string that AS can convert to a date object, ie 
"1/1/98", "February 6, 1998", etc.

     What's this for, anyway?  Why not use MacPerl time functions?  
Quick... what day of the week was March 15, 1925?  What weekday will June 
10, 2017 be?  The few extra microseconds it takes for this bit to run is 
worth not having to code something that will take a string that could 
maybe possibly be construed as a date and return a nice "Weekday, Month 
##, Year"...  :) 

     Any insights/suggestions/admonitions to "not try this at home 
without adult supervision" are appreciated... StdLog is available on 
request... I really want this, or some variation thereof, to be usable 
with MPW... I rarely even fire up the app anymore except under dire 
circumstances, like this one...  Help!

Vitals:
PCC PowerCenter Pro 180 64Mb
MacOS 7.6.1
MacPerl 5.1.9r4 (app and tool) app with 8Mb
MPW 3.4.2 running with 10Mb
MacsBug 6.5.4a3

TIA,

Rain

*********
     There are only three types of computer users. 

     Those that use Macs. 
     Those that wish they used Macs. 
     Those that don't know any better.



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