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 & HelpSyntax Questions › syntax error with a string array PLEASE help
Page Index Toggle Pages: 1
syntax error with a string array PLEASE help (Read 390 times)
syntax error with a string array PLEASE help
Mar 3rd, 2008, 7:43pm
 
hello,
i just started experimenting with processing.

it tells me i have a syntax error but  i don't
understand the suggestion to fix it

it says its expecting a semicolon.

expecting SEMI, found 'clintChop''

this is what i wrote so far:

void setup(){
 size (1000, 600);
 background (0, 55, 100);
}

void draw(){
 PFont fcb;
 fcb = loadFont("Futura-CondensedBold-36.vlw");
 textFont(fcb);
 
 String clintWhole[] = loadStrings("clintonOhio08.txt");
 for(int line = 0; line < clintWhole.length; line++){
   String clintChop[line] = split(clintWhole[line], " ");
 text(clintChop[75], 500, 300);
 }
 
 fill(255, 10);
   
 for(int i = 0; i < clintWhole.length; i++){
   for(int move = 0; move < height; move += 40){
   text(clintWhole[i], width- (width- 10), (height- (height- 40)));
   println(clintChop);
   }
 }

noLoop();

}

the error is  on line 13  
and if any one happens to see any other
violations as far as best practices or
can make suggestions it would
be a great help this is my first project
Re: syntax error with a string array PLEASE help
Reply #1 - Mar 3rd, 2008, 8:13pm
 
"String clintChop[line]=" makes no sense in this context. If you want to create an array, drop the contents of the [] e.g.
String clintChop[]= (or String[] clintChop=)

clintChop will then be an array of individual words, and you can then putt out the 75th word of a line the way you're trying to on the line below.

However in your second set of for loops, clintChop will not exist anymore, since you're creating it repeatedly in a for loop, it only exists within the for loop. To have it accesible outside, you'll need to do:
Code:
String[] clintChop;

for(....)
clintChop=....;



Re: syntax error with a string array PLEASE help
Reply #2 - Mar 3rd, 2008, 8:32pm
 
thanks for the speedy response!

so i have to make a new array out side of the for loops
and then i use can set the values for the array  inside the loop?  

my desired result was to have an array (clint Chop)
to get populated with every element as a word
from the txt doc.  

am moving in the right direction?
Page Index Toggle Pages: 1