Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!mit-eddie!bbn!rochester!pt.cs.cmu.edu!zog.cs.cmu.edu!tgl From: tgl@zog.cs.cmu.edu (Tom Lane) Newsgroups: comp.sys.mac.hypercard Subject: Re: if-statement problem (more info) Summary: I found out what HC does, but not why Keywords: syntax Message-ID: <3298@pt.cs.cmu.edu> Date: 13 Oct 88 23:06:54 GMT References: <10537@reed.UUCP> <3250@pt.cs.cmu.edu> Sender: netnews@pt.cs.cmu.edu Organization: Carnegie-Mellon University, CS/RI Lines: 45 Here's some more info about the problem Chris Langford posed, namely that if field 1 of cd i contains "RTFM" then fails while if field 1 contains "RTFM" then does not. It seems that following "card", "card id", "background", or "background id" (or abbreviations of same), HyperCard expects to find an arbitrary expression. This expression is everything up to the next "of", "in", "then", or similar keyword, end-of-line, or right parenthesis that matches a prior left parenthesis. Hence if (field 1 of cd i) contains "RTFM" then works. The same rule applies for expressions in a chunk-selector (i.e., following "char", "word", "item", or "line"). BUT: following "button", "button id", "field", or "field id", HyperCard expects to find a "factor" as defined on p. 49 of the Script Language Guide. This is: * a simple source of value (constant or variable name); * a parenthesized expression; * a factor preceded by "-" or "not". This explains why Chris's second example works: the "contains ..." is not part of the factor which is the field number. If you try something like put the name of field 1+1 you get a complaint, not the name of field 2. A factor is what is taken to be the argument of a parenthesis-less function; for instance, "the sqrt of 4+12" means "sqrt(4)+12", not "sqrt(4+12)". While I can think of arguments in favor of using either general expressions or factors as the value selecting an object, I find it hard to see why fields and buttons should be treated differently from cards and backgrounds in this regard. I also don't find anything about this topic in the Script Language Guide. (I derived the above rules by experiment.) Anybody from Apple care to comment? -- tom lane Internet: tgl@zog.cs.cmu.edu UUCP: !zog.cs.cmu.edu!tgl BITNET: tgl%zog.cs.cmu.edu@cmuccvma