FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   Problems defining an array
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Problems defining an array  (Read 220 times)
rgovostes

rgovostes
Problems defining an array
« on: Apr 3rd, 2004, 1:26am »

The following gives an "unexpected {" error on the "kernel = {" line... (please forgive formatting errors)
 
Code:
int[][] kernel;
void setup() {
  ...
  kernel = { /* Top, Left */ { (1), (width), (width + 1) },
                   /* Top */ { (-1), (1), (width - 1), (width), (width + 1) },
            /* Top, Right */ { (-1), (width - 1), (width) },
                  /* Left */ { (-width), (-width + 1), (1), (width), (width + 1) },  
                /* Center */ { (-width - 1), (-width), (-width + 1), (-1), (1), (width - 1), (width), (width + 1) },  
                 /* Right */ { (-width - 1), (-width), (-1), (width - 1), (width) },  
          /* Bottom, Left */ { (-width), (-width + 1), (1) },  
                /* Bottom */ { (-width - 1), (-width), (-width + 1), (-1), (1) },  
         /* Bottom, Right */ { (-width - 1), (-width), (-1) } };
}

 
What for?
« Last Edit: Apr 3rd, 2004, 1:27am by rgovostes »  
fry


WWW
Re: Problems defining an array
« Reply #1 on: Apr 3rd, 2004, 1:50am »

it's because that's not legal syntax in java, unfortunately. if you want to assign arrays using { and }, it has to be done when the thing array is declared, ie:
int[][] kernel = { .. your stuff here .. }
 
unfortunately you'll ahve to use a constant for the width & height since those variables won't exist (or they'll just be zero, rather.. or maybe 100) until you're inside of setup().
 
Pages: 1 

« Previous topic | Next topic »