Path: utzoo!attcan!uunet!samsung!crackers!m2c!umvlsi!umaecs!amh!mbabramowicz From: mbabramowicz@amherst.bitnet Newsgroups: comp.sys.mac.programmer Subject: Re: Timer Message-ID: <10719.271f09c1@amherst.bitnet> Date: 19 Oct 90 14:12:17 GMT Lines: 44 I think that it is possible to get better-than tick accuracy without installing any new hardware or relying on certain model Macintoshes. (Note: I haven't read the articles referenced previously, so perhaps someone has already written about this.) The for loop that someone suggested earlier is actually useful, with modifications: Time = Ticks(); for (count = 0; (count<= 2000) && (!Button()); count++); Time = Ticks() - Time; oneTick = 2000/Time; The variable oneTick is now set equal to the number of times you go through the for loop in a Tick. Then, if you want to track user reaction time, you use the same for loop as before. (To preserve the exactness of your count, be sure to keep in the count<=2000 line since that computation takes some time. You can make it count<= something big if you want the user to be able to take longer than 2000.) When the user hits the mouse button, the loop exits. count / oneTick * 60 should now give the time the loop took, in seconds. Dividing by 1000 gives milliseconds. Note of course that for accuracy oneTick should be a float or a double. If you use a number higher than 2000 you will obtain greater accuracy. This will work on any Macintosh, unless they make a Macintosh so fast that it can do 2000 iterations in less than a tick. (Maybe some now can do this. I don't really know. If so, just use 100,000 or a 1,000,000.) One little annoying thing about this method is what happens if the user presses the mouse button while you are doing your test? I haven't worked that out yet, but I doubt that a workaround would be complex. I haven't actually tried this out; this is all speculation; all disclaimers apply. Michael Abramowicz Amherst College