Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!ub!uhura.cc.rochester.edu!rochester!pt.cs.cmu.edu!h.gp.cs.cmu.edu!kem From: kem@h.gp.cs.cmu.edu (Kenneth Mohnkern) Newsgroups: comp.sys.mac.hypercard Subject: Re: if there is ... at [xx,yy] Message-ID: <12556@pt.cs.cmu.edu> Date: 1 Apr 91 16:20:15 GMT References: <12497@pt.cs.cmu.edu) <1991Mar30.180433.17363@ousrvr.oulu.fi) Organization: Carnegie-Mellon University, CS/RI Lines: 90 Thanks to everyone who sent me solutions to my request. Most didn't do exactly what I wanted, but I appreciate the efforts. The person who came closest to fulfilling my wishes was Ari Vaulo, who posted his solution here. It reads: ) my original problem: ) ) I guess HC2.0's "there is" doesn't have the ability to check if ) ) there's an object at a certain point. The manual doesn't cover ) ) "there is" very well. I think it's only mentioned in a table of ) ) functions (or commands? properties?) I tried "If there is a bg ) ) btn at 442,42 then beep". I got an error message. ) ) [blah, blah, blah...] ) ) I solved that kind of problem by clicking at the point where I supposed ) that there could be a button or something else. But it requires special ) code on every possible target. First I tried (with HC 2.0) the following ) command: ) click at xloc,yloc ) It was easy to look using TARGET function which object was at location ) (xloc,yloc), but it was a bit harmful because it executes all the mouse* ) command handlers and I should modify the command with shift,command, and ) option keys: ) click at xloc,yloc with cmdkey ) ) and in possible targets ) ) on mouseUp ) if the cmdKey is "down" then ) exit mouseUp ) else ) {code what the button should normally do} ) end if ) end mouseUp ) ) And at last I found that the possible solution isn't elegant, but it works. ) You should put the following code in your script where you want to find ) other objects: ) ) ... ) global KLIKATTU,OSUMA ) put empty into OSUMA ) put "Joo" into KLIKATTU ) click at xloc,yloc ) put empty into KLIKATTU ) if OSUMA is not empty then ) {the name of the object located at xloc,yloc is in variable OSUMA} ) {and it could be anything card, button, field, and so on. ) ... ) ) And in every object where is either some mouse* handlers or are your ) possible targets you should put the following code: ) ) on mouseUp ) global KLIKATTU ) if KLIKATTU is empty then ) {code what the object should normally do} ) else ) global OSUMA ) put the name of me into OSUMA ) exit mouseUp ) end if ) end mouseUp ) ) I don't like global with object oriented like code, but sometimes it is MUST. ) I'm trying to do draughts (or checkers) game with HC (I'm not sure that it ) will be ever ready) and there I need this kind of scripts. ) This is a pretty complex solution. I thought something like just: (in the card script) on mouseUp ... put theDesiredLocation into dLoc click at dLoc if the target contains "useful button" then -- I've found something good. else exit mouseUp -- or do something else... end mouseUp I'll fool with it a little and see where this gets bad results and why I'll need to use Ari's solution. Again, thanks to all. ken -- ken mohnkern#the robotics institute#carnegie mellon univ#pittsburgh pa