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

[MacPerl] toolbox gui script crashes MPW Shell



Environment: MPW Shell 3.5d1, MacsBug 6.5.4a3c1, MacOS 8.1,
MacPerl 5.2.0r4 app and tool


I am a rabid MPW Shell editor fan... I write all my scripts
and use them from MPW Shell.  I have no problems with other
scripts, and have even done some other gui scripts. However,
here is a script that runs under MacPerl, but crashes MPW
Shell. I loaded the MacPerl tool over the top of the MacPerl
application folder... is this a BAD thing?

When running this script, in MPW, the window frame, title bar, ok
button and default border, and cancel button draw, but, none
of the text items draw.  The camel cursor comes up and stays
spinning.  Sometimes pressing OK/Cancel quits the script,
but, selecting another window in MPW causes a *hard* crash,
necessitating cmd-cntrl-power reboot, and other times it does
not respond to the mouse, but cmd-period causes it to crash
(in _SetDeskCPat), and I'm able to escape to shell from
MacsBug and do a normal restart.

Also, I'd like to simply build the dialog in ResEdit and
load it with the appropriate 'new MacDialog' call. Is the
resource fork of the script opened, and "frontmost" so that
I can put the dlog in the script, and don't have to worry
about resource ID conflicts?


===== script =====
#!perl
	
	use Mac::Windows;
	use Mac::Dialogs;
	use Mac::QuickDraw;
	use Mac::Events;

	my($dlg, $bounds, $title, $dialogType);
	my($okBtnRect,$cancelBtnRect);
	my($hostTERect, $loginTERect, $passTERect, $pathTERect);
	my($hostCapRect, $loginCapRect, $passCapRect, $pathCapRect);
	my($done);

#	$i = 0;
#	printf "Here %d\n", $i++;

	$title  = 'Download File';
	$dialogType  = movableDBoxProc();

	# Rect->new(left, top, right, bottom)
	# OffsetRect(horiz, vert)

	# dialog bounds
	$bounds			= OffsetRect(Rect->new(0, 0, 482, 180), 50, 50);

	#OK and Cancel buttons
	$okBtnRect		= OffsetRect(Rect->new(0, 0, 80, 20), 43, 151);
	$cancelBtnRect	= OffsetRect(Rect->new(0, 0, 80, 20), 136, 151);
	
	# Text Edit rects
	$hostTERect    	= OffsetRect(Rect->new(0, 0, 180, 16), 105, 18);
	$loginTERect    = OffsetRect(Rect->new(0, 0, 180, 16), 105, 44);
	$passTERect    	= OffsetRect(Rect->new(0, 0, 180, 16), 105, 70);
	$pathTERect    	= OffsetRect(Rect->new(0, 0, 371, 16), 105, 105);
	
	# Caption rects
	$hostCapRect	= OffsetRect(Rect->new(0, 0, 95, 16), 2, 18);
	$loginCapRect	= OffsetRect(Rect->new(0, 0, 85, 16), 12, 44);
	$passCapRect	= OffsetRect(Rect->new(0, 0, 75, 16), 22, 70);
	$pathCapRect	= OffsetRect(Rect->new(0, 0, 65, 16), 32, 105);
	
	
	$dlg = new MacDialog $bounds,$title,1, $dialogType,1,
	(
		[ kButtonDialogItem,		$okBtnRect, 	"OK"	],
		[ kButtonDialogItem,		$cancelBtnRect, "Cancel"	],
		[ kEditTextDialogItem,		$hostTERect,	"" ],
		[ kEditTextDialogItem,		$loginTERect,	"" ],
		[ kEditTextDialogItem,		$passTERect,	"" ],
		[ kEditTextDialogItem,		$pathTERect,	"" ],
		[ kStaticTextDialogItem,	$hostCapRect,	"Remote Host" ],
		[ kStaticTextDialogItem,	$loginCapRect,	"Login Name" ],
		[ kStaticTextDialogItem,	$passCapRect,	"Password" ],
		[ kStaticTextDialogItem,	$pathCapRect,	"File Path" ],
	);
	
	SetDialogDefaultItem $dlg->window, 1; # make the OK button the default
	SetDialogCancelItem  $dlg->window, 2; # make the cancel button, well,  cancel

	$done = 0;
	$dlg->item_hit(1 => sub { $done = 1; });	# make the responses returned by the buttons
	$dlg->item_hit(2 => sub { $done = 2; });

	
	while ($dlg->window() && !$done)
	{
		WaitNextEvent();
	}

	$dlg->dispose();

===== script =====


Thanks!

Tom.

I must say that I find television very educational. The minute
somebody turns it on, I go to the library and read a book.
	-- Groucho Marx

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