I need a script to ...

Phil Davis revdev at pdslabs.net
Wed Mar 7 00:13:34 EST 2007


Hi Marc,

Marc Siskin wrote:
> I am working on a stack with 4 sections each section has more than 20 
> cards.   I need to limit the time spent on each section (e.g. 20 minutes 
> for section 1).  When the time is up I need to have the user taken the 
> end of that section.
> 
> I would appreciate script samples that will set the duration for a group 
> of cards and no matter where in that group skip to the end of the group 
> of cards when the time is up.
> 
> Any help would greatly appreciated.


Whenever you have a time limit like the ones you describe, you can use the timer 
built into one form of Rev's "send" command. For example, when a section is 
started, a handler somewhere could issue this command:

    send "moveToNextSection" to this stack in (20*60) seconds

That would cause the "moveToNextSection" handler to be executed in 20 minutes.

If a student finishes a section in less than 20 minutes, you probably want to 
cancel the command. here's how:


local vSectionTimer -- declared outside and above all handlers

on sectionStart
    send "moveToNextSection" to this stack in (20*60) seconds
    put the result into vSectionTimer -- the ID of this pendingMessage
end sectionStart


on sectionEnd -- student finished section in less than 20 min
    cancel vSectionTimer
end sectionEnd


on moveToNextSection
    go to last card of grp "Section1"
end moveToNextSection


You can trigger the Start and End handlers with openCard and closeCard handlers, 
and there are probably some other ways.

Take a look at 'the pendingMessages' also.

Hope this helps.
Phil Davis



More information about the use-livecode mailing list