Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!gdavis From: gdavis@primate.wisc.edu (Gary Davis) Newsgroups: comp.sys.mac.hypercard Subject: Re: How to find fields that DO NOT contain a string? Message-ID: <4507@uakari.primate.wisc.edu> Date: 13 Jun 91 07:45:11 GMT References: Sender: news@primate.wisc.edu Reply-To: gdavis@primate.wisc.edu Lines: 84 From article , by mike@ymt.com (Michael Czeiszperger): > Besides the basic telling whether a field does or does not contain > a certain string, I'm also looking to find a way for the user > to implement complicated searches without scripting. In a videotape > collection stack for instance, the user might want to find all > videotapes released by TouchStone Pictures between 1989-1990 that > are under 2 hours long. Writing a script won't work because the > search criteria would change each time. There are various ways to set up forms which a user could use to set up complicated queries. One way is to have a card with the same fields as occur on the regular collection cards. In your example, the user could just type something like "TouchStone Pictures" or "=TouchStone Pictures" or "<>TouchStone Pictures" in the "Producer" field and "< 2" in the Length field. The search script would use the values in the fields to carry out the search. Another approach is to use popup menus to supply the couplers: "is", "is not", "contains", "less than", etc, so the user doesn't have to know what to type in the fields. The scripting to carry out a search based on the entries in the search card can get somewhat complicated, but needn't be too bad. One way is to use "mark cards where" followed by a statement containg all the conditions, such as, mark cards where field "Producer" = "Touchstone" and field "Length" < 2 Instead of actual values in the statement you would use variables set from the fields on the search card. It may be more efficient in many cases to first "find" the cards where "Touchstone" is in "Producer" then check on the other conditions. Like this: put "Producer" into fieldToSearch put "Touchstone Pictures" into whatToFind put 2 into condition put "<" into comparisonOperator put "Length" into theField -- get these from the search card put "field" && theField && comparisonOperator && condition into conditionStatement unmark all cards mark cards by finding whatToFind in field whatToSearch unmark cards where value of conditionStatement is not true -- the conditionStatement could obviously be more complicated If you want to browse through cards rather than mark them all first, it would probably better to do a standard "find" followed by a check on the other conditions on goToNextCardMeetingCriteria repeat find whatToFind in field whatToSearch if the result is not empty then exit repeat -- exit if not found if value of conditionStatement then exit repeat -- to avoid an potentially infinite loop you would -- also need something like this if firstCardFound is empty then put number of this card into firstCardFound else if number of this card is firstCardFound then exit repeat end if -- firstCardFound would need to be a global and to be -- set to empty before entering loop end repeat end goToNextCardMeetingCriteria You might also want to look at the commercial product "Reports 2.0." It provides easy to use and fast methods for carrying out searches of essentially arbitrary complexity. Gary Davis