Adding text to file with void provisions? Look for text ("Hello", 30, 30); Syntax error.

edited September 2015 in Questions about Code
//// Wild circles #2.
String title=  "Click for another circle.";
String subtitle=  "Press any key to erase.";
String author=  "Bruce Alan Martin";

text("Hello", 30, 30);

// GLOBAL VARIABLES //
float x,y;
int h,w;

// Setup:  screen size, initialization. //
void setup() {
  size(500, 500);
  x=  width/2;
  y=  height/2;
  w=  80;          // width of ellipse.
  h=  80;          // height of ellipse
}


// Next frame. //
void draw() {
  text( title, 10, 10 );
  text( subtitle, width/2, 10 );
  text( author, 10, height-10 );
  text( w+"x"+h, width/2,height-10 );
  //
  ellipse(x, y, w, h);
}


//  Handle mouse clicks //
void mousePressed() {
  x=  mouseX;
  y=  mouseY;
}


//  Handle keyboard //
void keyPressed() {
  // Erase everything, change size & color. //
  background( random(255), random(255), random(255) );
  fill( random(255), random(255), random(255) );
  w=  int( random(50,150) );
  h=  int( random(50,150) );
}
Tagged:

Answers

  • please read sticky post how to format code

    go back and edit your post

  • I get the messages "you're mixing active and static modes," and "syntax error on tokens delete these tokens" which refers to the line text ("Hello", 30, 30);

  • line 6 is outside of any method.

    move it after line 23 and you'll see it.

  • edited September 2015

    Okay, so I moved it within the method of void draw and it still has a problem with the token "30"... is there a problem with those parameters or is it something else?

  • works ok here. please double-check.

  • edited September 2015
    //// Wild circles #2.
    String title=  "Click for another circle.";
    String subtitle=  "Press any key to erase.";
    String author=  "Bruce Alan Martin";
    
    // GLOBAL VARIABLES //
    float x,y;
    int h,w;
    
    // Setup:  screen size, initialization. //
    void setup() {
      size(500, 500);
      x=  width/2;
      y=  height/2;
      w=  80;          // width of ellipse.
      h=  80;          // height of ellipse
    }
    
    
    // Next frame. //
    void draw() {
      text("Hello," 10, 10);
      text( title, 10, 10 );
      text( subtitle, width/2, 10 );
      text( author, 10, height-10 );
      text( w+"x"+h, width/2,height-10 );
      //
      ellipse(x, y, w, h);
    } 
    
    //  Handle mouse clicks //
    void mousePressed() {
      x=  mouseX;
      y=  mouseY;
    }
    
    
    //  Handle keyboard //
    void keyPressed() {
      // Erase everything, change size & color. //
      background( random(255), random(255), random(255) );
      fill( random(255), random(255), random(255) );
      w=  int( random(50,150) );
      h=  int( random(50,150) );
    }
    
  • edited September 2015

    Is this what you did? Can you copy and paste your example?

  • Answer ✓

    Line 22 should read

      text("Hello", 10, 10);
    

    I changed the order of the second " and the first , .

  • Thank you! :) now I have a different problem of course lol.

Sign In or Register to comment.