The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

noplex (1) [Avatar] Offline

I'm pretty sure I'm being a bit dim, and I am very new to Processing, but I'm having a real problem positioning the custom function on Page 63, which returns a random value.

Wherever I put the code chunk - in amongst the code made during the previous few listings - I get an error message "It looks like your mixing "active" and "static" modes."

Is it me (likely) or is there a problem with the listing?

haha1111 (5) [Avatar] Offline
Re: Page 63, Ch 3
The error message is non-obvious. If you follow the sequence of the examples in the book, you 'll get the error. The problem is the main program is not in a function. When it encounter a new function declaration, it barfed. To fix the error, put the main function as part of setup(){} . i.e.

//add this
void setup() {

//insert listing 3.2
float xstep = 1;
float lastx = -999;
lasty = y;
//add this
//now the function
float customRandom() {
float retValue = 1 - pow(random(1), 5);
return retValue;