| Reference | Downloads | Github

General Questions Regarding JS Conversion & Crib Sheet

A few general questions I am hoping people can help me out with…

  1. The crib sheet that is going around suggests that anyone using the most up-to-date version of Psychopy V2020.1.3 should get rid of some general python code and replace it manually with JS code…

for example, (take straight from the crib sheet)

thisExp —> thisExp=psychoJS.experiment;

There are many of these. My question is, why is it that if I use ONLY the builder (and I add no code of my own), I can export the HTML code and upload this to Pavlovia without an issue (I have tried this with a simple experiment and it worked perfectly). That suggests that the ‘thisExp’ code that is written in Python is successfully translated into JS…is that correct?

If so, why should someone change these at all? It clearly can run with that code…

  1. If I set my Code Type to “Both”…I see the code that I originally wrote on the left, and the translated code on the right. Can I edit the code on the right manually and have those changes saved, and then export to HTML?

  2. If I am unable to get my HTML to export (it does not show ‘successful’ ever), does that suggest that I have an error in the code and need to change my code in a way that it will compile in JS?
    If yes, how do I find the error in the code? I see quite a few places where people are suggesting that you use the web browsers JavaScript compiler, but I am very unfamiliar with that. Is there a way one can tell what the errors are more easily? Or more information on how to read those errors?

  1. I think you might be missing the point of the crib sheet. This is for experiments with code components (or which need code components because they have Python functions as parameters of their Builder components.

  2. Yes, that is usually the point of Both. Auto translate and then switch to Both for the manual edits.

  3. I don’t select Export HTML. Rather I sync the project. Errors with syncing are a separate issue and probably aren’t related to JavaScript errors

I understand that the cribsheet is for experiments with additional code…I am attempting to run one of those experiments. I guess more clearly stated, these suggestions are for only the additional code, NOT code that the builder generates…is that correct?

Can you help clarify how one might track down errors with JS? I am sure I have them in my additional code, but finding them is an issue. Thanks

I have never yet made an edit to the JS file

Sorry, another question to your third comment…if I attempt to sync the program, my Psychopy freezes up (tells me it is not responding)…does that suggest a specific error?

Thank you for your response, I am going to be a clear as I can, please stick with me…THis is the first part of my additional code…

original_file = pd.read_csv(‘Final_large_file_conditions.csv’)
condition_file = original_file.loc[ original_file[‘Subject’] == int(expInfo[‘participant’]) ]
condition_file.to_excel(‘condition_file.xlsx’, index = None, header=True)

If I set my Code Type to “Both”…I should be able to change this code to JS on the right side? Correct?

If so, I am not using append…should I still be using Array.prototype.append = [].push; from the crib sheet?

Pandas won’t work I’m afraid

You don’t need code for append = push if you aren’t using append

Yes, very aware Pandas wont work here :slight_smile: Any ideas on how to bring in a CSV file without using Pandas? A previous thread that you were on suggested this code for bringing in data…

My apologies, I am very new to javascript

Now you need append