Best way to set up an idle timer - The prize goes to...

Devin Asay devin_asay at byu.edu
Mon Aug 18 13:57:00 EDT 2003


Thanks to Dar, Sarah and Edwin, and Jan (and anyone else I'm 
forgetting) for their help on this. It's working flawlessly now.

This bit was especially helpful, Sarah:

On Monday, August 18, 2003, at 01:27  AM, Sarah 
<sarahr at genesearch.com.au> wrote:

> Other people have suggested storing the result of the "send" and using
> that as a cancel parameter, but I prefer to be more heavy-handed than
> that, as I find that this still leaves the possibility of spawning
> multiple messages:
>
> Put the following handler in your stack script and in resetLogout,
> replace the first line with:
>     cancelMessageName logoutQuery
>
> on cancelMessageName handlerName
>    put the pendingMessages into pMess
>    repeat for each line p in pMess
>      if item 3 of p contains handlerName then cancel item 1 of p
>    end repeat
> end cancelMessageName
>
For anyone interested, this is what I ended up with:

==============start script sample (line wrapping alert!)============
-- first of all, put into an otherwise unused script:
on mouseMove
   send "resetLogout" to stack "chinpr"
   pass mouseMove
end mouseMove

on rawKeyDown
   send "resetLogout" to stack "chinpr"
   pass rawKeyDown
end rawKeyDown

-- then I put into my stack script:
on openStack
   -- my other openStack junk here
   insert the script of image "P&Rbg1.jpg" of stack "chinpr" into front 
-- this handles mouseMove and rawKeyDown
   resetLogout -- start the logout countdown
end openStack

on logoutQuery
   if the userPIN of this stack is not empty then
     beep
     answer "An appropriate prompt here." with "Logout" or "Enter PIN..."
     if it is "Enter PIN..." then -- (user chose to continue)
       repeat
         ask "Enter your PIN to continue the test."
         if it is the userPIN of this stack then
           resetLogout
           exit repeat
         else
           answer information "Incorrect PIN. Try Again or Logout?" with 
"Logout" or "Try Again"
           if it is "Logout" then
             go card "menu" of stack "chinpr"
             logout
             exit repeat
           end if
         end if
       end repeat
       exit logoutquery
     else if it is "Logout" then -- (user chose to log out)
       go card "menu" of stack "chinpr"
       logout
       exit logoutQuery
     end if
   end if
end logoutQuery

on resetLogout
   --  cancel item 1 of last line of the pendingMessages
   put the pendingMessages into pndgMsgs
   repeat for each line thisMsg in pndgMsgs
     if item 3 of thisMsg contains "logoutQuery" then cancel item 1 of 
thisMsg
   end repeat
   send "logoutQuery" to stack "chinpr" in 5 * 60 seconds -- or whatever 
time period you want
end resetLogout

========================end script sample==========================

Devin Asay
Humanities Technology and Research Support Center
Brigham Young University




More information about the use-livecode mailing list