Home > Uncategorized > How To implement Timers

How To implement Timers

Overview

SurveyToGo supports usage of Timers.
Timers, as expected, are used to act as stop watch’s.
This How-To will introduce you to basic usage of timers in a few simple steps:
Step 1: Configuring a basic timer.
Step 2: How to use the time measured by a timer.
Step 3: Configuring an Action for elapsed timers.
Let’s Go !

Step 1: Configuring a basic timer.

Setting a timer is done by using the Set Timer function.
The Set Timer function gets 3 Parametrs, for example:
Timers.SetTimer(“myTimer”,30000,false);

1st Parameter: Name of the timer as a string.
2nd Parameter: Time in milliseconds.
3rd Parameter: Boolean value – ‘true’ for reactivating the timer each time it is being elapsed,
‘false’ for NOT reactivating the timer each time it is being elapsed.

This script better be written in a Start Script of the question where you would like to start it.

If needed, you can also stop the timer inside a Start\End Script, for example:
Timers.PauseTimer(“myTimer);

1st Parameter: Name of the timer to pause as a string.

Step 2: How to use the time measured by a timer.
Let’s say we want to measure a time between a beginning of a timer and a “Pause” of a timer.
This link will show you which script you should add in addition to your timers:
https://manual.dooblo.net/2012/08/09/how-to-measure-time-between-questions/


Step 3: Configuring an Action for elapsed timers.

Timers are enabled to have an ‘Action’ when a timer is elapsed, in order to configure such an action, you would need first of all to add this function to the ‘Advanced Scripts’ (Exactly is written):

function OnTimer(key)

{

}

This function is activated every time a timer in the survey is elapsed and runs the code written inside of it.
So, in order to configure a separate action for each timer you can add ‘if’ statements, for example:

function OnTimer(key)

{

    if(key==“MyTimer”)

    {

        Prompt(“MyTimer was elapsed!!!”);

    }

}

This function, would check if the current “key” (name of the timer that was elapsed) is equal to “MyTimer” (the name of the timer we configured), if it does, it would execute the code I wrote.
You can add an ‘if’ for each timer in the survey (if an action needed), for example:

function OnTimer(key)

{

    if(key==“MyTimer”)

    {

        Prompt(“MyTimer was elapsed!!!”);

}
if(key==“test1”)

    {

        Prompt(“test1 was elapsed!!!”);

    }

if(key==“test2”)

    {

        Prompt(“test2 was elapsed!!!”);

    }

}

If you wish to move to the next question once a timer is elapsed, you can use the following code:
ExecutionMgr.GotoNext()

However, any action needed can be scripted.

That’s it!

Visit us at: http://www.dooblo.net

Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: