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 › unexpected token: int
Page Index Toggle Pages: 1
unexpected token: int (Read 642 times)
unexpected token: int
Apr 14th, 2010, 2:15pm
 
Hello everyone,
I came back with one more problem......
The error message given is:Unexpected token: int
It's highlighted on:

if(range(red_over_green,RG_min_for_background,RG_max_for_background)&&all_greate
r_than_3(red_in,green_in,blue_in,background_threshold))
{
 return "background";// For background: red_over_green must be with the range RG_min_for_background and RG_max_for_background,
                     //all color values must be over background_threshold
}

This if statement is within a String type function.range() and all_greater_than_3 are just two simple functions that return 1 for true and 0 for false.These two functions are int type.

There are also some other similar if statement included in the same String type function.

I spent 2 hours trying to find out what the problem is .Can anyone help me please? Cry
Re: unexpected token: int
Reply #1 - Apr 14th, 2010, 3:10pm
 
I think your question could be a little clearer and could do with a bit more context.  You also provide a couple of lines of code and don't specify which of them it actually throws the error on.

Having said that the solution seems obvious enough: if your range() and all_greater_than_3() functions return ints then you need to make you condition a little more specific.  IIRC some languages will treat a '0' as equivalent to boolean false and any number greater than zero as a boolean true, so you can get away with phrasing the condition the way you do.  But in Processing you need to test like for like: i.e. if you're dealing with ints, rather than booleans, you need to test them as ints NOT as booleans - i.e.:

if(range([args]) >0) { // equivalent to if(true) where 0 represents false

Mind you Processing normally throws a clearer error than 'unexpected token: int' in these circumstances...  Still with the information you provide that's my best offer...
Page Index Toggle Pages: 1