Debugging Your Scripts

Saturday, February 14th, 2009 | Interviewing, Scripting

We were recently asked if it was possible to debug an interview but starting at question 10 not question 1. There are several ways we can debug our iom scripts and this article talks us through a few common ways.

Before we can start learning how to debug we need a script, so create an MDD file with the following in it.

Metadata(en-AU, Question, label)
Q1 "Question_Text_Goes_Here" categorical [1]
{ _1 "1",_2 "2",_3 "3",_4 "4",_5 "5" };
Q2 "Question_Text_Goes_Here" categorical [1]
{ _1 "1",_2 "2",_3 "3",_4 "4",_5 "5" };
Q3 "Question_Text_Goes_Here" categorical [1]
{ _1 "1",_2 "2",_3 "3",_4 "4",_5 "5" };
Q4 "Question_Text_Goes_Here" categorical [1]
{ _1 "1",_2 "2",_3 "3",_4 "4",_5 "5" };
Q5 "Question_Text_Goes_Here" categorical [1]
{ _1 "1",_2 "2",_3 "3",_4 "4",_5 "5" };
End Metadata

and we will need the following routing

Routing(Web)
Q1.ask(
Q2.ask()
Q3.ask()
Q4.ask()
Q5.ask()
End Routing

 General Debuging

When we come to debug our scripts we have several tools at our disposal. They are

Continue with Auto Answer: This is used to quickly get to the breakpoint in your survey without having to answer the questions yourself.

Break Points: A break point is a mark in your script that mrStudio knows to stop at when running so that you can look at things and then single step the rest of the survey. To aply you break poin left mouse click the left of your mrStudio to produce a brown line across the screen. To remove the break point click the circle on the left hand side again.

Q3 Break Point

Q3 Break Point

In our example we needed to click to the left of the number five in the image above to place and remove the break point.

Single Step:  This allows us to move through our questionaire on line at a time when we are running. This means we can begin to discover what our problem may be with the help of the localwindow. 

Single Step

Single Step

Locals Tab :  As we move through our script in debug mode we can use the locals window to discover the content of variables etc. Select the question on the right hand side iof the screen that you wish to explore and click the + signs to dive deep into the object and discover its values.

Locals Window

Locals Window

Expressions Tab : You can also use the expressions window that can be found at the bottom of the screen. This tab allows you to enter the code and then click evaluate and show you the results. In our example we used the format function to show  us the value entered at question 2

Expresions tab

Expressions tab

Using the tools to debug your scripts

So now we know a little about the tools we have to play with, how do we use them? Its simple really , first we need to decide how we want to debug, do we want to start at the very first question or do we want jump to a particular question and start debugging, first we will look at stating at the beginning

Option 1 :  Starting the begining

Firstly we select the routing that we want to debug and the we make sure that we have the browser tab selected down the bottom of the page also,

Starting to debug

Starting to debug

then we start our script in the normal way by clicking the play button. Then we can select our answers in the browser and debug our survey whenever we want with the use of the local windows or the expression tab. The survey will just pause as you explore the properties of your questions. ( Notice the yellow line move and you answer your questions , this shows you where you are in the script )

Survey started

Survey started

 

Option 2 : Using a Test Routing

Another good way to debug your scripts is to create a test routing, this way you can easily just look at just the bit of code you are interested in. For example : click the create new routing button ,call it test,

Test Routing

Test Routing

then past the section of code in you want to look at eg

Routing(Test)
Q3.ask()
Q4.ask()
Q5.ask()
End Routing
Test Routing with questions

Test Routing with questions

Option 3 : Starting from Q3

If we want to start our debug session from a question other than the first what we can do is to put our breakpoint on the question we want to start at

Q3 Break Point

Q3 Break Point

and then start the survey with the “Continue With Autoanswer” button.

Continue With Auto Answer

Continue With Auto Answer

This method will use auto answer to get to your break point and then you can use the “single step” button to move on one step at a time.

Single Step

Single Step

No comments yet.

Leave a comment

Categories

Blog Counts

Search

Archives

PHP Notice: A feed could not be found at http://twitter.com/statuses/friends_timeline/16449757.rss in F:\hshome\anncoona\smarterdimensions.com\Blog\wp-content\plugins\external-rss-reader\inc\simplepie.inc on line 1780