Loading...
Logo
Processing Forum
Hi everyone! I'm trying to write a function inside another function. Both return float values but for some reason (probably something really stupid I've overlooked or simply ignored) processing is giving me a unexpected token:float error. The code in particular is the following. Thanks a lot for your help!!!

Copy code
  1. float numberbeans() {
  2.   current();
  3.   curb= map(curmili, 0, totalmili, 0, totalbeans);
  4.   
  5.   float current() {
  6.     curs=second();
  7.     curh=hour();
  8.     curd=day();
  9.     curm=month();
  10.     curml=millis();
  11.     cursec=((((curm-1)*30+curd)-1)*24+curh)*3600+curs;
  12.     curmili=(cursec-1)*1000+curml;
  13.     return(curmili);
  14.   }
  15.   return(curb);
  16. }

Replies(3)

In Java, you just cannot do that... No nested functions. (Unlike Pascal/Delphi, Scala, etc.) That's an inheritance of C language.
you can wrap your function in a class, which can be defined inside a function itself. of course this doesnt make any sense here, ... but this you can do in java
Thanks a lot! I managed to get around it