I am obtaining a String from the apsync.*; library. It is very reliable but I have to declare it as a
public String.
Later I am trying to compare it to a local string and get a True or false.
Here is the code simplified based on the Processing example.
import apsync.*;
AP_Sync streamer0;
public String str0 = "CCdCP";
String str1 = str0;
String str2 = "CCCP";
// Tests to see if 'str1' is equal to 'str2'
if (str1.equals(str2) == true) {
println("Equal"); // They are equal, so this line will print
} else {
println("Not equal"); // This line will not print
}
I get the error:
Illegal modifier for parameter str0; only final is permitted
What am I doing wrong?
To summarize:
I want to obtain a string from AP SYNC and compare it to a local value such as "25A" or a local string equal to that.
If they are equal , then my code should execute, etc.
Thanks
Very odd, I can reproduce it using Processing v3.5.3. You should create an issue in Processing Github. I am assuming this is caused by the error checker having a bug. Or I can create it for you. Just let me know.
@laptophead ===
that is not a bug, that is because in your code you are using local variables and modifiers have not any sense in this case, except for final: other modifiers have sense only for class variables which can be accessed (or not) by other classes. Writing as below and the error disappears.
public String str0 = "CCdCP";
// Tests to see if 'str1' is equal to 'str2'
void setup(){
String str1 = str0;
String str2 = "CCCP";
if (str1.equals(str2) == true) {
println("Equal"); // They are equal, so this line will print
} else {
println("Not equal"); // This line will not print
}
}
@akenaton Thanks for your input. That makes sense.
@laptophead To explain this a bit more. When you write code in Processing, people use either use the static approach as in your provided example or they can include setup-draw functions to draw a series of frames. Processing tanspilates your code into Java. This includes arranging your code into a class. Your code above will be placed inside the setup() function. Hence, the public modifier does not apply.