Millisecond Forums

By-experiment randomization of text locations

https://forums.millisecond.com/Topic19255.aspx

By AndrewJSchoen - 6/14/2016

Hi all,

I have a task that I am creating, during which the participant selects a choice from a set of 6 text-buttons, arranged in two columns (2x3). Therefore, there are 6 possible locations for the buttons, and locations cannot be repeated. Right now, the locations are statically set, but I would like to set them at the beginning of the experiment, and then use those locations for the rest of the experiment. Here is a snippet of the text code:

<text happiness>
/ items = ("Happiness")
/ hjustify = center
/ vjustify = center
/ fontstyle = ("Arial",5%, false, false, false, false, 5, 1)
/ txcolor = white
/ txbgcolor = grey
/ position = (30%, 20%) #As you read ahead, this will have to be set from values.happiness_position, or something similar...
/ size = (20%, 10%)
/erase = false
</text>


In order to do it, I thought I may make some variables as such:

<values>
/ anger_position = (0%,0%)
/ happiness_position = (0%,0%)
/ sadness_position = (0%,0%)
/ fear_position = (0%,0%)
/ disgust_position = (0%,0%)
/ surprise_position = (0%,0%)
</values>


And then also have some locations:

<list button_position_1>
/ items = (30%, 20%)
</list>

<list button_position_2>
/ items = (30%, 50%)
</list>

<list button_position_3>
/ items = (30%, 80%)
</list>

<list button_position_4>
/ items = (70%, 20%)
</list>

<list button_position_5>
/ items = (70%, 50%)
</list>

<list button_position_6>
/ items = (70%, 80%)
</list>



 Finally, I thought a noreplace would be the solution to set the values, but I do not have the syntax correct:


/ onexptbegin = [values.anger_position, values.happness_position, values.sadness_position, values.fear_position, values.disgust_position, values.surprise_position = noreplace(list.button_position_1.items, list.button_position_2.items, list.button_position_3.items, list.button_position_4.items, list.button_position_5.items,list.button_position_6.items)]



Any suggestions or solutions would be greatly appreciated!
Thanks!

Andy
By Dave - 6/14/2016

#1: You need separate <values> entries (variables) for each <text> element's x and y position.

<values>
/ anger_x = 0%
/ anger_y= 0%
/ happiness_x = 0%
/ happiness_y = 0%
...
</values>

#2: Reference those in your <text> elements like this:

<text happiness>
/ items = ("Happiness")
/ hjustify = center
/ vjustify = center
/ fontstyle = ("Arial",5%, false, false, false, false, 5, 1)
/ txcolor = white
/ txbgcolor = grey
/ hposition = values.happlness_x
/ vposition = values.happiness_y

/ size = (20%, 10%)
/erase = false
</text>

#3: You need two paired <list>s. One holding the x-positions, another one holding the corresponding y-positions:
<list button_x>
/ items = (30%, 30%, 30%, 70%, 70%, 70%)
/ selectionrate = always
</list>

<list button_y>
/ items = (20%, 50%, 80%, 20%, 50%, 80%)
/ selectionmode = list.button_x.currentindex
/ selectionrate = always
</list>

#4: Finally, you need to set the <values> to items sampled from those lists /onexptbegin:

/ onexptbegin = [values.anger_x = list.button_x.nextvalue; values.anger_y = list.button_y.nextvalue;
values.happiness_x = list.button_x.nextvalue; values.happiness_y = list.button_y.nextvalue; ...]