Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uwm.edu!lll-winken!aunro!alberta!arcsun.arc.ab.ca!arcsun!kenw From: kenw@skyler.arc.ab.ca (Ken Wallewein) Newsgroups: comp.sys.mac.hypercard Subject: Re: How to tell when really idle? Message-ID: Date: 7 May 91 18:46:21 GMT References: <1991May5.214456.5228@dartvax.dartmouth.edu> Sender: nobody@arc.ab.ca (Absolutely Nobody) Organization: Alberta Research Council, Calgary Alberta, Canada Lines: 66 In-Reply-To: Eric.J.Baumgartner@dartmouth.edu's message of 5 May 91 21:44:56 GMT Here's what I finaly came up with. It saves after 2.5 minutes of no menu or keyboard activity -- mousing isn't likely to cause problems if menus aren't involved. It has occured to me that this is only needed if a text field is actually open, because closing a field writes it, but I haven't optimized for that yet; it doesn't seem needed. on openStack -- initialize globals; s/b "on startUp"? global active,lastAction,shortIdle put false into active put false into shortIdle put the seconds into lastAction pass openStack end openStack -- based on idle checker idea from Frank Vernon, 9to5 S/ware on idle global active,lastAction,lastOnIdle,shortIdle if the seconds-lastOnIdle >60 then -- only check occasionally get the seconds put it into lastOnIdle if active then -- remember when (approx) if active in last minute put true into shortIdle put it into lastAction put false into active end if if shortIdle then -- do stuff once when short idle times out if it-lastAction >150 then -- if no activity last 2.5 minutes doKeep put false into shortIdle end if end if end if end idle on keyDown -- do minimum amount of work here global active put true into active -- put "keyDown handled" pass keyDown end keyDown on doMenu -- some changes do not involve keys down global active put true into active -- put "doMenu handled" pass doMenu end doMenu on doKeep -- force the stack to write down to disk get the selectedChunk -- set cantModify of this stack to true -- set cantModify of this stack to false push card -- this is quicker pop card put the name of this stack && "KEEP done at" && the time select it end doKeep -- /kenw Ken Wallewein A L B E R T A kenw@noah.arc.ab.ca <-- replies (if mailed) here, please R E S E A R C H (403)297-2660 C O U N C I L