(newbie)Badly formed character constant (expection quote. got e)

I just try to see this work into my processing.


var gl,noctaves,c;
function setup() {
  createCanvas(windowWidth, windowHeight,WEBGL);
    test=new p5.Shader(this._renderer,vert,frag);//shaders are loaded
  shader(test);//shaders are applied    
function draw() {    
    test.setUniform("iResolution", [width,height]);//pass some values to the shader
  test.setUniform("iTime", millis()*.001);
function mouseReleased(){
function initc(){
    for(var i=0;i<22;i++){
        else c[i]=random(-1,1);

but when I paste that code and press launch, I meet this message with fail

Badly formed character constant (expection quote. got e)

processing.app.SketchException: Badly formed character constant (expecting quote, got e) at processing.mode.java.preproc.PdePreprocessor.checkForUnterminatedMultilineComment(PdePreprocessor.java:888) at processing.mode.java.preproc.PdePreprocessor.write(PdePreprocessor.java:925) at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:253) at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:156) at processing.mode.java.JavaBuild.build(JavaBuild.java:123) at processing.mode.java.JavaBuild.build(JavaBuild.java:105) at processing.mode.java.JavaMode.handleLaunch(JavaMode.java:122) at processing.mode.java.JavaEditor.lambda$0(JavaEditor.java:1097) at java.lang.Thread.run(Thread.java:748)

what can I do?


  • Can you please format your code?

  • edited February 2018

    @KevinWorkman I'm not sure what you asking exactly. but

    If you ask my processing version, I'm using 3.3.6 32bit version.

    If you ask what I type more. I just copying as ctrl+a and ctrl+v

  • We can't really read your code. Please format the code in the editor. There's a code button, or look at how other posters have formatted their code.

  • edited February 2018

    @KevinWorkman Thanks. I edit it.

  • When I try to run your code, I get an error on this line:

    test=new p5.Shader(this._renderer,vert,frag);//shaders are loaded

    The error says that vert is not defined.

  • edited February 2018

    Thanks Kevin. I think I just need to learn more..

  • edited February 2018 Answer ✓

    Do you need to use double quotes on line 4?

    In Java, single quotes are generally used for a single character, so it's expecting another quote after the w but getting e instead. That would explain the message. JavaScript might be different though.

  • JavaScript is different. You can use either a single quote or a double quote to use a string literal.

  • hence my proviso at the end there.

    and that's no reason to mix them willy-nilly in the code though.

    (i'm also not entirely convinced the error in the first post is a javascript error what with all the processing.mode.java.JavaEditor.* stuff)

  • (which you can verify by pasting the above into the pde in java mode)

  • The error says that vert is not defined.

    there's a second tab in the openprocessing page

  • Thank @koogs I was think all code in openprocessing is working without mistake. I think it's bit hard to understand your advise.. now I learning hard with book to understand more.. thanks :(

  • edited March 2018

    1. The openprocessing sketch has two tabs.
    2. Did you copy the contents of both tabs (mySketch and shaders) into your desktop sketch?
    3. A missing tab of code might be one reason why you are getting an error.

  • No, my last message was quoting Kevin who appears to have missed the second tab when trying to reproduce the problem

    YunJae's problem appears to be trying to use the code from openprocessing in Java mode.

  • edited March 2018

    I think its worth pointing out that this sketch i not written in java, but in javascript. The two languages are similair, but different.

    For example while processing/java uses void setup(){}and void draw(){} etc, openprocessing/javascript uses function setup(){} and function draw(){} etc.

    You can't run javascript in an editor that expects java and vise versa. As @koogs points out, that is probably the source of your problem.

    As you learn more programming, these differences will become more obvious to you and it might be possible for you to translate the code from one language to another or just rewrite the sketch.

    Good luck :)

  • @jeremydouglass , @koogs , @Eyeorelife

    Thanks guys. I think i can understand little bit more. I didn't know about second tab and I didn't know about different modes. I was find some more codes that didnt work in sketch from openprocessing and that moment I realize what you guys says.. because, these codes can't find from my books.

    Thank you guys and I hope I understand well for this time..

Sign In or Register to comment.