Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Variable values in loop not synchronized

edited January 14 in OpenSesame

Hi folks,

I have a loop that contains a sequence. In the sequence there is an inline script that increments an experimental variable. (The variable was initialized to zero before the loop.) Immediately after the script I have a text form that displays the value of the variable. I can see that the variable value is correct by looking at it in the variable inspector and by printing its value out in the debug window. However, the value displayed in the text form is incorrect - it is the value the variable had before the latest increment, i.e., what it had on the last iteration of the loop. How can I fix this?

Here's a simplified, concrete example:

Before the loop I set the variable (total_points) to zero, e.g.,

var.total_points = 0


In the first iteration of the loop:

a. the inline-script increments the value by 10, e.g. var.total_points +=10

b. the variable inspector and the printout in the debug window both show that var.total_points is 10

c. the text form has the line "You have a total of [total_points] points" . The form displays

"You have a total of 0 points", which is incorrect


In the second iteration of the loop:

a. the inline-script increments the value by 10, e.g. var.total_points +=10

b. the variable inspector and the printout in the debug window both show that var.total_points is 20

c. the text form displays "You have a total of 10 points", which is incorrect. Note that the form is displaying the value of total_points from the previous iteration


In the third iteration of the loop:

a. the inline-script increments the value by 10, e.g. var.total_points +=10

b. the variable inspector and the printout in the debug window both show that var.total_points is 30

c. the text form displays "You have a total of 20 points", which is incorrect. Note that the form is displaying the value of total_points from the previous iteration


etc.


Any suggestions? (I have OpenSesame 3.2.8 running on Windows 10.)

Thanks.

Greg Reese

Sign In or Register to comment.