psychopy.org | Reference | Downloads | Github

Saved click is not a function - Help

URL of experiment: https://pavlovia.org/kparks7/hebbianlearning

Description of the problem:
I am encountering an issue with one of my functions when I try to put my experiment up on Pavlovia. I think it has something to do with the python - js translation because I have dealt with this before but I’m not sure how to remedy this specific issue. Every time I try to run the experiment, it says ‘saved click is not a function’ but I can’t find an equivalent js function to replace it. I’m also struggling to find a similar problem online.

In my experiment, the participant needs to order a series of syllables. When they are finished ordering, there is a ‘finished’ button they must click at the bottom of the screen but it flashes the error ’ saved click is not a function’ and without this code, the same trials will just keep repeating without moving onto the next. Could someone please help me? Any help at all is VERY much appreciated.

This is my code in JS:
saved_click = [];
for (var i, _pj_c = 0, _pj_a = mouse_5.clicked_name, _pj_b = _pj_a.length; (_pj_c < _pj_b); _pj_c += 1) {
i = _pj_a[_pj_c];
saved_click.append(eval(i.slice(1)).text);
}
thisExp.addData(“saved_click”, saved_click);

Thank you so much.

What does your pre-auto translation Python code look like?

Do you have a code_JS component as per my crib sheet?

Here is a screenshot and I will take a look - this sheet looks incredibly helpful. I have tried to look online for compatible functions but I’m not sure I understand python enough to know exactly what I am looking for!

Are you able to use the Browser cosole to find out what line the error is in?

I’m not sure that you can save an array to the data file in JS in the same way you can in Python. Please could you test this by trying to save saved_click[0] ?

1 Like

One of my friends was actually able to solve this problem by changing the append part of the code to saved_click.push:

saved_click = [];
for (var i, _pj_c = 0, _pj_a = mouse_5.clicked_name, _pj_b = _pj_a.length; (_pj_c < _pj_b); _pj_c += 1) {
i = _pj_a[_pj_c];
saved_click.push(eval(i.slice(1)).text);
}

psychoJS.experiment.addData(“saved_click”, saved_click);

Thank you for helping me on this problem and my other one wakecarter! :slight_smile:

If you use my code_JS component you don’t need to do append = push or thisExp = psychJS.experiment every time

1 Like