Auto transcription error

Hi All,

My team and I have created an experiment which has lots of code components in it, all of which has auto translated into JS OK. However, when we try and run it online we get the error Uncaught SyntaxError: Unexpected token ‘var’ which I believe is due to an auto translation error in psychopy for a few of our text components (possibly something to do with the code we’ve written). In the JS script the code is:

// *GRDinvesttotal* updates    
if ((var _pj;
function _pj_snippets(container) {
    function in_es6(left, right) {
        if (((right instanceof Array) || ((typeof right) === "string"))) {
            return (right.indexOf(left) > (- 1));
        } else {
            if (((right instanceof Map) || (right instanceof Set) || (right instanceof WeakMap) || (right instanceof WeakSet))) {
                return right.has(left);
            } else {
                return (left in right);
            }
        }
    }
    container["in_es6"] = in_es6;
    return container;
}
_pj = {};
_pj_snippets(_pj);
_pj.in_es6(mode, ["investing", "closing_time"])) && GRDinvesttotal.status === PsychoJS.Status.NOT_STARTED)

The problem is coming from this if statement if (( var _pj; but I’m unsure as to what it is doing. I could manually remove the var but would have to do this every time I make a change. Any suggestions on how to fix this issue?

Thanks in advance for any responses

Please could you show your Python code as well (in the code components that run up to and including the error)?

Hi Wakecarter,

Thanks for replying so fast.

I’m not sure if this code needs to stay private or not so is there a way I can send you the psychopy directly?

Thanks

You can send me the psyexp file via PM. Do you have any variables or componented called var?

Hi Wakecarter,

Sorry I can’t see a way to PM on here do you have a preferred method? Email, linkedin?

No, no variables or components called var

Thanks

1 Like

When I open your experiment I get an error:

UnicodeDecodeError: ‘charmap’ codec can’t decode byte 0x9d in position 4087: character maps to

I think this means that a non standard character is being read as code.

However, your experiment won’t run online because it imports numpy.

Have a look at my troubleshooting document
https://psychopy.org/online/psychoJSCodingDebugging.html

and my crib sheet

Hi Wakecarter,

Ah that’s an interesting error. We haven’t seen that one on our end. I will try and replicate it and see if we can fix it.

I didn’t realise that. We will work on a work around for numpy then and see where we end up.

Thanks for all your help and for the quick turn around on this