"-1" is not a valid variable name
Hi there,
I'm running a sustained attention task in which the participant is required to shift their attention to the other side of the display (left, right) every 20 trials. I've tried using the following inline script at the top of my trial sequence:
if (var.count_trial_sequence%20) == 0:
var.set(var.valid_side,var.valid_side*(-1))
valid_side has a value of -1 or +1 and is used as a multiplier with other variables to determine target position. I want its sign to flip every 20th trial. When I try to run my experiment, which ran fine before, I get the following error:
"-1" is not a valid variable name
item-stack: experiment[run].practice_loop[run].oneblock_sequence[run].block_loop_repeat_trial_several_times[run].trial_sequence[prepare].new_inline_script_1[prepare]
time: Wed Nov 02 15:24:59 2016
Not sure why it thinks -1 is a variable name? I've tried doing the same thing several ways, including defining an intermediate variable, changing its value, and then setting valid_side to equal the intermediate variable, but I get the same error.
Any help would be very greatly appreciated!
Thanks ![]()
-Jonathan

Comments
Hi Jonathan,
The error message is right.
-1is indeed not a valid variable name, because python variables are not permitted to begin with numbers. What you meant to do is this:var.set('valid_side',var.valid_slide*(-1)). However, an easier and more intuitive way of doing it, would be this:var.valid_side *= -1.Hope this helped.
Eduard
Ohhh I see. Thanks so much, Eduard!