Dynamically changing values stored in list


Author
Message
Jakob
Jakob
Respected Member (440 reputation)Respected Member (440 reputation)Respected Member (440 reputation)Respected Member (440 reputation)Respected Member (440 reputation)Respected Member (440 reputation)Respected Member (440 reputation)Respected Member (440 reputation)Respected Member (440 reputation)
Group: Forum Members
Posts: 8, Visits: 27
I am rather self-taught in programming these experiments and tend to do things a bit unconventionally, sometimes. But maybe you can help me again (as you have done before).

I built a very complicated trial, which I want to “recycle” (repeat). That works perfectly fine using lists, except for storing/saving values within those trials.

In my script I run through the same block multiple times. With the help of lists, I can change the stimuli dynamically. But I do not know, how to dynamically save values, for a repeated block.

What I want: Save the value.current_click (similar to a counter) dynamically.
My approach: I have a list with the values

<list list_responses>
/items = (values.DRAWStrial1, values.DRAWStrial2, values.DRAWStrial3)
/selectionmode = (values.current_list)
</list>

<values>
/DRAWStrial1 = -88
/DRAWStrial2 = -88
/DRAWStrial3 = -88
</values>


Then, at the end of the block, I want to simply change the current value in the list. My most intuitive approach was /onblockend = [list.list_responses.nextvalue=values.current_click] but it says “the expression attempts to set the value of read-only property”:
<block someblock>
/trials = [1-12 = trial_choose]
/onblockend = [list.list_responses.nextvalue=values.current_click]
</block>

<expt>
/ blocks = [1-3= someblock]
</expt>

<summarydata>
/ columns = [values.DRAWStrial1, values.DRAWStrial2, values.DRAWStrial3]
</summarydata>


I tried other functions like
/onblockend = [list.list_responses.setitem(values.current_click, values.current_list)]
and
/onblockend = [ list.list_responses.item(values.current_list)=values.current_click]

Not always I get an error message, but it never saves the value.current_click to the values “stored” in my list list_responses to be saved in summarydata. The value always stays at the value -88 (pre-defined at the beginning of script).

Another idea I had was to create values somehow on the fly using dynamically created strings. For this I would need to convert my “list-counter” to a string, concatenate this to “value. DRAWStrial” and save the values.current_click to it.
Any help appreciated! Thanks a lot! 😊

Dave
Dave
Supreme Being (818K reputation)Supreme Being (818K reputation)Supreme Being (818K reputation)Supreme Being (818K reputation)Supreme Being (818K reputation)Supreme Being (818K reputation)Supreme Being (818K reputation)Supreme Being (818K reputation)Supreme Being (818K reputation)
Group: Administrators
Posts: 10K, Visits: 57K
Jakob - 4/18/2020
I am rather self-taught in programming these experiments and tend to do things a bit unconventionally, sometimes. But maybe you can help me again (as you have done before).

I built a very complicated trial, which I want to “recycle” (repeat). That works perfectly fine using lists, except for storing/saving values within those trials.

In my script I run through the same block multiple times. With the help of lists, I can change the stimuli dynamically. But I do not know, how to dynamically save values, for a repeated block.

What I want: Save the value.current_click (similar to a counter) dynamically.
My approach: I have a list with the values

<list list_responses>
/items = (values.DRAWStrial1, values.DRAWStrial2, values.DRAWStrial3)
/selectionmode = (values.current_list)
</list>

<values>
/DRAWStrial1 = -88
/DRAWStrial2 = -88
/DRAWStrial3 = -88
</values>


Then, at the end of the block, I want to simply change the current value in the list. My most intuitive approach was /onblockend = [list.list_responses.nextvalue=values.current_click] but it says “the expression attempts to set the value of read-only property”:
<block someblock>
/trials = [1-12 = trial_choose]
/onblockend = [list.list_responses.nextvalue=values.current_click]
</block>

<expt>
/ blocks = [1-3= someblock]
</expt>

<summarydata>
/ columns = [values.DRAWStrial1, values.DRAWStrial2, values.DRAWStrial3]
</summarydata>


I tried other functions like
/onblockend = [list.list_responses.setitem(values.current_click, values.current_list)]
and
/onblockend = [ list.list_responses.item(values.current_list)=values.current_click]

Not always I get an error message, but it never saves the value.current_click to the values “stored” in my list list_responses to be saved in summarydata. The value always stays at the value -88 (pre-defined at the beginning of script).

Another idea I had was to create values somehow on the fly using dynamically created strings. For this I would need to convert my “list-counter” to a string, concatenate this to “value. DRAWStrial” and save the values.current_click to it.
Any help appreciated! Thanks a lot! 😊

I have no idea what you're trying to do. You say you want to "change the current value in the list". What is the current value? You have three variables as that list's items. values.DRAWStrial1, values.DRAWStrial2, and values.DRAWStrial3. Simply set whatever value or values of those three to values.current_click. There's no reason to do anything with the list at all.

<block someblock>
/trials = [1-12 = trial_choose]
/onblockend = [if (values.current_list == 1) {values.DRAWStrial1 = values.current_click};
    if (values.current_list == 2) {values.DRAWStrial2 = values.current_click};
    if (values.current_list == 3) {values.DRAWStrial3 = values.current_click};
    ]
</block>


Jakob
Jakob
Respected Member (440 reputation)Respected Member (440 reputation)Respected Member (440 reputation)Respected Member (440 reputation)Respected Member (440 reputation)Respected Member (440 reputation)Respected Member (440 reputation)Respected Member (440 reputation)Respected Member (440 reputation)
Group: Forum Members
Posts: 8, Visits: 27
Thank you very much for the fast reply. That would do the job. This is probably the best approach for Inquisit, I guess. Yet, I was looking for a more "dynamically approach", as I have ten or more trials, and per trial I want to save more than one value. That would mean lots of hardcoded lines. Thats why I came up the idea to use a list with values, trough which I am itterating with a counter (values.current_list) and to change the list's element (values) dynamically.

Dave
Dave
Supreme Being (818K reputation)Supreme Being (818K reputation)Supreme Being (818K reputation)Supreme Being (818K reputation)Supreme Being (818K reputation)Supreme Being (818K reputation)Supreme Being (818K reputation)Supreme Being (818K reputation)Supreme Being (818K reputation)
Group: Administrators
Posts: 10K, Visits: 57K
Jakob - 4/19/2020
Thank you very much for the fast reply. That would do the job. This is probably the best approach for Inquisit, I guess. Yet, I was looking for a more "dynamically approach", as I have ten or more trials, and per trial I want to save more than one value. That would mean lots of hardcoded lines. Thats why I came up the idea to use a list with values, trough which I am itterating with a counter (values.current_list) and to change the list's element (values) dynamically.

You can use <list>s, but there's no point in using values as the list's items.

Jakob
Jakob
Respected Member (440 reputation)Respected Member (440 reputation)Respected Member (440 reputation)Respected Member (440 reputation)Respected Member (440 reputation)Respected Member (440 reputation)Respected Member (440 reputation)Respected Member (440 reputation)Respected Member (440 reputation)
Group: Forum Members
Posts: 8, Visits: 27
Dave - 4/20/2020
Jakob - 4/19/2020
Thank you very much for the fast reply. That would do the job. This is probably the best approach for Inquisit, I guess. Yet, I was looking for a more "dynamically approach", as I have ten or more trials, and per trial I want to save more than one value. That would mean lots of hardcoded lines. Thats why I came up the idea to use a list with values, trough which I am itterating with a counter (values.current_list) and to change the list's element (values) dynamically.

You can use <list>s, but there's no point in using values as the list's items.

Thank you. I thought that would be an easier and more elegant way to store values from a repeated trial. But I guess I will have to do it with the if statements with expressions for each repeated trial. Thank you for this suggestion!
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search