We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › bug I'm pretty sure it wasn't a month ago..
Page Index Toggle Pages: 1
bug I'm pretty sure it wasn't a month ago..? (Read 760 times)
bug I'm pretty sure it wasn't a month ago..?
May 15th, 2010, 12:30pm
 
Code:
void setup() {
size(500,500);
smooth();
background(255);
}

void draw() {
kurve(2,3,4);
}

void kurve(a,b,c) {
noFill();
translate(250,250);
stroke(0);
beginShape();
for (float x=-250;x<250;x++)
{
vertex(x,-a*x*x-b*x-c);
}
endShape();

return();
}






I'm pretty sure it worked a month ago, but now there's the message:

expecting IDENT, found ","

what's the matter?
Re: bug I'm pretty sure it wasn't a month ago..?
Reply #1 - May 15th, 2010, 1:05pm
 
1. Declare the datatype of the variables in your function (for example int or float)

2. Functions declared with void can't return values and shouldn't include a return value. See the reference.

Also, if you want to use this function more than once consider adding translate(-250,-250); at the end. Otherwise it works cumulatively.

Code:
void setup() {
 size(500,500);
 smooth();
 background(255);
}

void draw() {
 kurve(2,3,4);
}

void kurve(int a, int b, int c) {
noFill();
translate(250,250);
stroke(0);
beginShape();
for (float x=-250;x<250;x++)
{
 vertex(x,-a*x*x-b*x-c);
}
endShape();

}
Re: bug I'm pretty sure it wasn't a month ago..?
Reply #2 - May 15th, 2010, 1:19pm
 
thank you.  Smiley

how stupid.. I should know that  Wink
Page Index Toggle Pages: 1