Path: utzoo!attcan!uunet!husc6!bloom-beacon!gatech!udel!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(?) Summary: Another HC syntax bogosity Keywords: if syntax Message-ID: <3250@pt.cs.cmu.edu> Date: 9 Oct 88 18:06:15 GMT References: <10537@reed.UUCP> Sender: netnews@pt.cs.cmu.edu Organization: Carnegie-Mellon University, CS/RI Lines: 65 In article <10537@reed.UUCP>, langford@reed.UUCP (Chris Langford) writes: > [...] When I try to run scripts that contain if statements with this format: > > if field 1 of cd i contains "RTFM" then > > I get an error message that says "No such card". The problem is fixed if > I write the script: > > get field 1 of cd i > if it contains "RTFM" then > > or like this: > > go cd i > if field 1 contains "RTFM" then > The problem goes away if you add some parentheses: if (field 1 of cd i) contains "RTFM" then Evidently, when you write the command without parentheses, HC parses it as if field 1 of cd (i contains "RTFM") then hence the error "no such card" (unless you have a card named "false"). It would seem that after "card" HC looks for a general expression, whereas after "field" it looks for a more restricted expression---since Chris's last example is not parsed as if field (1 contains "RTFM") then This sort of undocumented inconsistency is the reason why people have been complaining since day one about HyperCard's weird syntax. Has the HC team ever heard of formal syntax specifications (e.g., BNF notation)? If so, why do they still refuse to publish one? There is nothing about the relative precedence of arithmetic operators and chunk-expression operators in the HyperCard Script Language Guide, and certainly nothing to suggest that arithmetic expressions in different parts of a chunk expression will be parsed differently. I get the impression that Apple believes that formal specifications would scare away potential scripters who don't understand formal methods. I beg to differ. Failing to publish a formal specification for HyperTalk syntax is not going to make scripting any easier; it just creates more room for problems of the kind shown above. (A truly scary thought is that Apple doesn't *have* a formal specification, and will be as surprised as the rest of us by problems of this ilk.) I don't want to offend anybody at Apple, but I do think it's high time to publish a *complete* specification of the language. Failure to do so suggests that they do not understand their product any better than the rest of us. -- tom lane Internet: tgl@zog.cs.cmu.edu UUCP: !zog.cs.cmu.edu!tgl BITNET: tgl%zog.cs.cmu.edu@cmuccvma