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 › Very Very Quick Function Question
Page Index Toggle Pages: 1
Very Very Quick Function Question (Read 356 times)
Very Very Quick Function Question
May 8th, 2008, 5:07am
 
Why can't I get the variable a from ttime();?




int dub;
int val = 0;



void draw(){
ttime();
println(a);
}


void ttime(){

String lines[] = loadStrings("list.txt");
  dub++;
 

   if(dub>=lines.length-1){
  exit();
 }
int a = int(lines[dub]);

 
}
Re: Very Very Quick Function Question
Reply #1 - May 8th, 2008, 5:30am
 
I did it!

I'm still wondering if there is a better way. This seems kind of backwards to me.


Quote:


int dub;
int val = 0;



void draw(){
int t = ttime(val);
println(t);
}


int ttime(int b){

String lines[] = loadStrings("list.txt");
  dub++;
 

   if(dub>=lines.length-1){
  exit();
 }
int a = int(lines[dub]);
   //println(int(lines[count]));
b = a;
// println("there are " + lines.length + " lines");
//println(a);
 return b;
}

Re: Very Very Quick Function Question
Reply #2 - May 8th, 2008, 9:43am
 
You don't need to pass an int into that function:

Code:
int ttime(){
String lines[] = loadStrings("list.txt");
dub++;
if(dub>=lines.length-1){
exit();
}
return int(lines[dub]);
}

Page Index Toggle Pages: 1