Path: utzoo!censor!geac!torsqnt!lethe!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!usc!zaphod.mps.ohio-state.edu!ub!uhura.cc.rochester.edu!rochester!pt.cs.cmu.edu!o.gp.cs.cmu.edu!andrew.cmu.edu!jk3t+ From: jk3t+@andrew.cmu.edu (Jonathan King) Newsgroups: comp.sys.mac.hypercard Subject: Re: Another idling in pre-2.0 HC, AND file problems (pre 2.0) Message-ID: <4bXHT_e00WB3QEWbhf@andrew.cmu.edu> Date: 11 Jan 91 03:58:02 GMT References: <1991Jan10.170207.23311@usenet.ins.cwru.edu> Organization: Psychology, Carnegie Mellon, Pittsburgh, PA Lines: 101 In-Reply-To: <1991Jan10.170207.23311@usenet.ins.cwru.edu> mike@pyrite.SOM.CWRU.Edu (Michael Kerner) writes: > Well, I trashed the message that some helpful soul sent out, so I don't know > who he is, however, it really doesn't help. It wasn't me; maybe you were thinking about Chaz Larson (who posted an answer)? And, as you'll see, it really *did* help if you extended the idea just a little bit. > I don't want a global variable > 'cause I want to reset the timer if something happens, which is why I wanted > to trap myself in the idle. But you can access a global variable where ever you want. So, suppose you want to reset the timer when the user pushes a button. Then you put the following in your mouseUp handler: on mouseUp global timer blahblahblah put the ticks into timer end mouseUp And similarly in the other handlers you have that respond to events you care about. In particular, you can reset the timer whenever the user types something by handling keydown messages. A slightly neater way (which will be a teeny bit slower) of doing the above is to write a special handler that resets/increments/checks the timer and call it when you need to. Thus: on mouseUp timer reset doYourDance pass mouseUp end mouseUp on idle timer checktimeout if the result is "timeout" then doYourIdleTask end if pass idle end idle --the following handler, timer, does several different things. --the first argument specifies what you want to do with your timer, --while the second (optional argument) is for resetting the cutoff --variable (how many ticks you want to wait until timing out) --Note that HC will just put empty into newvalue if you call timer --with only one arg. --Also note that returning from a non-function handler sets 'the --result', as demonstrated here. on timer command, newvalue global idletime --the ticks at the last action global cutoff --the number of ticks until overflow if command is "reset" then put the ticks into idletime return empty --everything's fine else if command is "newcutoff" then put newvalue into cutoff return empty else if command is "checktimeout" then if (idletime - the ticks) > cutoff then put the ticks into idletime return "timeout" else return empty end if --for the incredibly neat people in our audience else answer "Illegal argument to timer" with "OK" end if end timer This way, only one handler has access to the timer global variables, which is slightly neater if you're into information hiding, and the name of the handler is more obvious. > That is why the screen saver analogy is good - I > want to keep counting until either my timer runs out or something happens. > > Any guesses? I hope the above helps... > Second question: related to files: I'm importing a file edited by an IBM. > The file is unformatted by the IBM editor, but two strange things happen with > it. Here's the script > [deleted] I don't immediately understand the question, so I'll punt on this one. jking