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 › VariableDeclaratorId error Spliting array object
Pages: 1 2 
VariableDeclaratorId error Spliting array object (Read 1919 times)
Re: VariableDeclaratorId error Spliting array obje
Reply #15 - Mar 20th, 2007, 7:37pm
 
That appears to be whats happening. The "mosa-dtlz1-run1.txt" im testing with can be found in this package. Shouldnt be big.

http://www.dcs.ex.ac.uk/people/kismith/mosa/results/tec/mosa-tec-reference-resul...
Re: VariableDeclaratorId error Spliting array obje
Reply #16 - Mar 20th, 2007, 8:00pm
 
String lines[] = loadStrings("mosa-dtlz1-run11.txt");
double[][] doubles = new double[lines.length][0];
int numValues = 0;
for ( int i=0; i < lines.length; i++ ) {
   String[] svals = split(lines[i]);
   double[] dvals = new double[svals.length];
   for ( int s=0; s < svals.length; s++ ) {
       dvals[s] = Double.parseDouble(svals[s]);
   }
   numValues += dvals.length;
   doubles[i] = dvals;
}

println( "found: "+numValues+" values in "+lines.length+" lines" );

i don't have any problems here ... 3 values per line, 333 lines = 999 values. perfect.
Re: VariableDeclaratorId error Spliting array obje
Reply #17 - Mar 20th, 2007, 8:12pm
 
Thank you very much! works a treat.

I believe the problem was when i was adding this code to test the output...
Code:
for ( int i=0; i < lines.length; i++) {
println(doubles[i]);
}


clearly im not calling back out of the doubles[] array properly. To think this is just the start of my program, eek.

Andrew.
Re: VariableDeclaratorId error Spliting array obje
Reply #18 - Mar 20th, 2007, 8:52pm
 
Fixed, this seems to be doing the job, forgot I was calling from a multidimensional array.  

EDIT: tidied for input with k entries per line.
Code:

for ( int i=0; i < lines.length; i++) {
for ( int k=0; k < kvals; k++){
print(" "+doubles[i][k]);
}
print("\n");
}




Thanks for all the help, I imagine it wont be long before im back though.
Andrew
Pages: 1 2