Post by florian on Dec 5, 2020 13:18:16 GMT
Hello,
I have a problem with the (new) array function "set ... uniq" - or maybe it just doesn't work properly?
I've written a visual working memory task in which 8 filled dots of a 4x4 matrix are to be recalled by clicking on them. Order should be irrelevant. The indices of to-be-remembered dots are contained in the table columns @17-@24 and end up in an array &&seq, and the clicked positions are to be stored in the array &&sel. Currently, participants can click on the same dot multiple times (which is fine), but if they click on a correct dot eight times in a row, then the feedback will be "8 correct", which should not be the case (it should be "1 correct"). I've tried several things and the most straigtforward solution seems to be using the "set ... uniq" function. So to avoid the problem, I wanted to remove all the duplicate items in the array of clicked positions: set &&sel uniq. Unfortunately, it doesn't work, and the duplicates will still counted as correct responses (i.e., increase the variable &ncorr). You will find the task code for the recall procedure below. Any hints or suggestions would be highly welcome!
Best,
Florian
...
mouse show
set &&seq clear
set &&seq append @17
set &&seq append @18
set &&seq append @19
set &&seq append @20
set &&seq append @21
set &&seq append @22
set &&seq append @23
set &&seq append @24
set &&seq sort
set &&sel clear
set &counter 0
while &counter < 8
set &counter increase
readmouse l &&seq[&counter] 60000 range 1 16
set &&sel append UNDER_MOUSE
set $mx getx UNDER_MOUSE
set $my gety UNDER_MOUSE
show circle $mx $my 20 255 0 128
delay 100
while-end
clear screen
set &&sel sort
set &&sel uniq
set $nsel &&sel size
set $i 0
set &ncorr 0
while $i < 8
set $i increase
set $j 0
while $j < $nsel
set $j increase
if &&seq[$i] == &&sel[$j]
set &ncorr increase
fi
while-end
while-end
show text &ncorr -50 0 0 0 0
show text " correct!" 50 0 0 0 0
delay 1000
set &&seq clear
set &&seq append @17
set &&seq append @18
set &&seq append @19
set &&seq append @20
set &&seq append @21
set &&seq append @22
set &&seq append @23
set &&seq append @24
set &&seq sort
set &&sel clear
set &counter 0
while &counter < 8
set &counter increase
readmouse l &&seq[&counter] 60000 range 1 16
set &&sel append UNDER_MOUSE
set $mx getx UNDER_MOUSE
set $my gety UNDER_MOUSE
show circle $mx $my 20 255 0 128
delay 100
while-end
clear screen
set &&sel sort
set &&sel uniq
set $nsel &&sel size
set $i 0
set &ncorr 0
while $i < 8
set $i increase
set $j 0
while $j < $nsel
set $j increase
if &&seq[$i] == &&sel[$j]
set &ncorr increase
fi
while-end
while-end
show text &ncorr -50 0 0 0 0
show text " correct!" 50 0 0 0 0
delay 1000