Can you add "use strict"; as the first line in your sketch? Not sure if it would help, but that is that first thing I would try. I am also very curious to know what editor you are using.
Thanls Kevin. Actually, the following example works fine in browser and is editable on other editors like Alpha web editor, Notepad++ and Netbeans. All of them do not claims for a syntax error.
const PASSWORD_MIN_LENGTH = 4;
function setup() {
createCanvas(400, 400);
alert(PASSWORD_MIN_LENGTH);
}
function draw() {
background(220);
}
But what I’ve just observed is that if I create a new p5.js sketch into Processing IDE and paste the above code, everything works fine in browser and editor. So I must investigate what’s the difference between my project code and my test code. It’s late but I’m gonna do it as soon as possible. In the same time, I’m gonna try to make a MCVE, good idea!
Kevin, is the following MCVE enough? I’ve done this MCVE by making a copy of the p5.js sketch from Processing IDE, with the ‘Save as…’ command. Still the same error. BUT when I create a new p5.js sketch into Processing IDE and replace the default .js and .html code with a copy of the MCVE code, the error does not occurs… I’m asking myself if this could result of a file corruption (problem of character encoding for instance)…
.js
const PASSWORD_MIN_LENGTH = 4;
var username;
var password;
var firstname;
var lastname;
var birthday;
var birthMonth;
var birthYear;
var gender;
var statusMsg = "";
function setup() {
createCanvas(windowWidth, 50);
}
function draw() {
}
.html
<html>
<head>
<meta charset="UTF-8">
<!-- PLEASE NO CHANGES BELOW THIS LINE (UNTIL I SAY SO) -->
<script language="javascript" type="text/javascript" src="libraries/p5.js"></script>
<script language="javascript" type="text/javascript" src="libraries/p5.dom.js"></script>
<script language="javascript" type="text/javascript" src="MCVE.js"></script>
<!-- OK, YOU CAN MAKE CHANGES BELOW THIS LINE AGAIN -->
<!-- This line removes any default padding and style.
You might only need one of these values set. -->
<style>
body {padding: 0; margin: 0; font-family:Arial, Helvetica, sans-serif;}
</style>
</head>
<body>
</body>
</html>
Thanks Kevin. I tried it yesterday (copy / paste solution), but it… failed. After this I’ve closed the Processing IDE, I’ve opened the *.js file with an editor (Atom, apparently the one used by Daniel Shifman into his famous videos). Everything worked fine at execution into browser and Atom editor didn’t point a syntax error. But if I reopen the corrected sketch back into Processing IDE I get exactly the same error. So it’s still a mystery. Bug into Processing IDE code parser? Should I put this thread into github Processing developpers forum?
Thanks for your help ! At least I’ve got an alternative for the moment. I’m gonna open an issue on GitHub. I wanted first to be sure it was not an error of mine. 'hope it could be corrected even if it’s not a priority issue.