[comp.sys.mac.hypercard] Confused Novice

john@aplcomm.JHUAPL.EDU (John Hayes) (05/18/91)

Hello,
	I am a Hypertalk novice and I find myself baffled by its syntax.
I frequently type in reasonable looking code; when it doesn't work
I rarely understand why and must resort to experimentation to make it
work.  Here is the most recent example:

-- this doesn't work
put the id of card into placeHolder

-- this works
get the id of card
put it into placeHolder

-- this also works
put the id of this card into placeHolder -- 'this' must be there!@!#

	The first example sometimes causes Hypercard to complain "can't
understand this" and sometimes "card doesn't exist".  The second example
works.  Then I found that preceding 'card' with 'this' makes the
first example work; I don't know why.

	I am an experienced programmer and know many languages, but I
continually come up against problems like the one above.  Can anyone
recommend a book that accurately and completely describes the syntax
and semantics of Hypertalk?

P.S.  I have Goodman/The Complete Hypercard Handbook and Shafer/Hypertalk
Programming.

John R. Hayes			john@aplcomm.jhuapl.edu
Applied Physics Laboratory
Johns Hopkins University

grobbins@Apple.COM (Grobbins) (05/18/91)

In article <424@aplcomm.JHUAPL.EDU> john@aplcomm.jhuapl.edu (John Hayes) writes:
>	I am a Hypertalk novice and I find myself baffled by its syntax.
>I frequently type in reasonable looking code; when it doesn't work
>I rarely understand why and must resort to experimentation to make it
>work.

There are rules, but their similarity to English is sinister rather
than helpful for scripters.

>-- this doesn't work
>put the id of card into placeHolder

"card" isn't sufficient to specify the object.  These are better:

  this card
  third card
  the third card
  card 3
  card "frump"
  card id 5713

Only objects which are truly unique, like msg and HyperCard, are used 
without a name, id number, or ordinal.

>-- this works
>get the id of card
>put it into placeHolder

HyperTalk will stretch to understand you, and this can cause confusion.  
If you end a line with "of card" or "of background" HyperCard will
assume you meant "of this card" or "of this background".  But "of card"
and "of background" are not proper identifiers, and HyperCard really
should consistently reject them.  Generally you will have to identify
cards, backgrounds, and other objects with a name, id number, or
ordinal.

>	I am an experienced programmer and know many languages, but I
>continually come up against problems like the one above.  Can anyone
>recommend a book that accurately and completely describes the syntax
>and semantics of Hypertalk?

The most sophisticated and frank published account I've seen is
"HyperTalk 2.0: The Book" by Winkler and Kamins.  The Claris manual
is a tad more complete as a reference of keywords, however.


Grobbins                     grobbins@apple.com
Usual disclaimers apply.

glenn@gla-aux.uucp (Glenn Austin) (05/24/91)

In article <424@aplcomm.JHUAPL.EDU>, john@aplcomm.JHUAPL.EDU (John Hayes) writes:
> -- this doesn't work
> put the id of card into placeHolder

it needs to know which card!  card which?  card ID 123?  card "Foo"?

> -- this works
> get the id of card
> put it into placeHolder

there is no ambiguity.  Card is at the end of the line and isn't followed
by anything else, so it must be this card

> 	I am an experienced programmer and know many languages, but I
> continually come up against problems like the one above.  Can anyone
> recommend a book that accurately and completely describes the syntax
> and semantics of Hypertalk?

Get the Claris development release of Hypercard.  I understand the documentation
is _very_ well written.  I currently use the HyperCard Script Language Guide,
with some help from the HyperTalk Reference Stack.

===============================================================================
| Glenn L. Austin                | "Turn too soon, run out of room.           |
| Macintosh Wizard and           |    Turn too late, much better fate."       |
| Auto Racing Driver             |   -- Jim Russell Racing School Instructors |
|-----------------------------------------------------------------------------|
| Usenet:  glenn@gla-aux.uucp         | CI$:       76354,1434                 |
| GENie:   G.AUSTIN3                  | AOnline:   GAustin                    |
===============================================================================

mike@pyrite.SOM.CWRU.Edu (Michael Kerner) (06/01/91)

Probably the best novice/medium user guide would be The Waite Group's HyperTalk
Bible.  It gives pretty good examples to follow through that should help.  When
Apple didn't include scripting manuals with HC a few years back I bought it and
have since then gotten my Graduate Assistantship at Case and an awesome full
time job.  The syntax isn't bad.  While it may be verbose, you will find that
it helps later.  Basically you need to make your code look like English and
chances are it will be close to working.  There are also some non-intuitive
things that happen with ordinals but after you get used to it I think you won't
ever go back to any other language - I used to do work in FORTRAN, COBOL,
Pascal, 950 different versions of BASIC, APL, ProLog ADA, LISP, etc. but I've
found that HyperCard is the easiest environment to do development in, as well
as the easiest code to pick up (i.e. someone else's) and read.

Mike.