[comp.sys.mac] HyperTalk messages

gjditchfield@violet.UUCP (10/14/87)

I have some questions about HyperTalk's pre-defined messages.  I am hoping
that someone will tell me that HyperCard 1.0.1 is not the most recent
version, or that these are bugs that will be fixed soon, or that the way
HyperTalk works really does make sense.

Create a 'junk' stack.  (I used the 'New Stack' menu item while I was in
the Address book stack.)  Go to a background card and put these messages in
the script.
	on newCard
		answer "New Card"
	end newCard

	on openCard
		answer "Open Card"
	end openCard
Close the script and create a new card.  I get the "Open Card" dialog
_before_ the "New Card" dialog.  This seems wrong to me.  I want to use
openCard to perform actions when a card is opened, based on the values in
certain card fields, and use newCard to initialize those fields, but the
current order prevents that.  My work-around assumes that fields are
initialized to "", and I don't like that.

(Example: Chuq's radio buttons.  An invisible field holds the name of the
button that should be highlighted for this card, and newCard initializes it
to the name of the default button.)

Next, create or select a background field.  (I used the "Name and Address"
field.)  Put these messages in the field's script.
	on openField
		answer "Open:" & line 1 of field "Name and Address"
	end openField

	on closeField
		answer "Close:" & line 1 of field "Name and Address"
	end closeField
Close the script and click on the field, then immediately click elsewhere.
I get the "Open" dialog, but not the "Close" dialog.  Click on the field,
type something, and click elsewhere.  I get both dialogs.  This is exactly
what I want: the closeField message is sent only if the content of the
field changed.

Now, click on the field, type something, and click somewhere else in the
_same_ field.  I get two "Open" dialogs, but no "Close" dialog.  This seems
wrong.  Either I have not re-opened the field, in which case I should only
get one "Open" dialog, or I have re-opened the field, in which case I
should have got a "Close" dialog, since I changed the field contents before
the second click.  (I prefer the first alternative.)

(Example: I want the contents of a field to be automatically entered in an
index.  The obvious solution was
	on openField
		-- save the current value of the field
	end openField

	on closeField
		-- remove the old value from the index
		-- add the new value to the index
	end closeField
but this doesn't work if the user changes the insertion point while editing
the field.)

The answers to my last questions are probably obvious to everyone but me.
- Is there a better way to send a message with arguments than
	send "msgName" && quote & argString & quote to someThing?
- I don't think a field's name should be hard-coded into its scripts, as
  was done with "Name and Address" above.  "Line 1 of me" and "Line 1 of
  this field" don't work.  "Line 1 of the target" gives me the field's
  name, not the contents.  What is the correct incantation?
--
Glen Ditchfield                      {watmath,utzoo,ihnp4}!watrose!gjditchfield
Dept of Computer Science, U of Waterloo         (519) 885-1211 x6658
Waterloo, Ontario, Canada			   Office: MC 2006
If you grab the bull by the horns, you at least confuse him -- R.A.Heinlein