Hello,i have these two functions in the end of a code and i call into the draw() the function displayinformation() to show in the screen of Android the characteristics(Name, age,…) everytime i select a specific choice from a list. My problem is that after this procedure i want to send an OscMessage with this characteristics and i do not know how can i add the Information from the void Information function as a string.
void displayinformation(){
if (selection.equals("1")) {
Information("John", 30);
}
if (selection.equals("2")) {
Information("Melanie", 40,);
}
}
void Information (String name, int age) {
textSize(60);
fill(0);
text("Name:"+name, 800,500);
fill(0);
text("Age:"+age, 850, 600);
}
If you need something out of a function, it can’t return void (nothing)! You could return a String.
And method (function) names should start lower-case by convention.
String information (String name, int age) {
textSize(60);
fill(0);
text("Name:"+name, 800,500);
fill(0);
text("Age:"+age, 850, 600);
return "Name: " + name + "\nAge: " + age;
}
I have also tried the string function but when i put the name as as string in the function myMessage.add(name) into draw the console shows me that the variable name does not exist.
Is there a way that i can add in the OscMessage the function displayinformation()???
i just want to send wireless in my PC via oscP5 library whatever is into display() method into draw().
Something like :
OscMessage myMessage = new OscMessage ( "Characteristics" + information );
myMessage.add(displayinformation);
oscP5.send(myMessage, remoteLocation);
not this way, you use in the creation of “myMessage” information displayinformation
in the wrong way.
displayinformation does not return a string
information might if you call it correctly
if using @neilcsmith example:
information(“Anna”,77)
could do the job by returning “Name: Anna\nAge: 77”
and put it also to the canvas window.
this mix might not be wanted.
i cant change the format of displayInformation() to string because i call this method into draw() to show me the information(nam, age ,…) in the Android screen.
i know that this wrong but i want to explain you that i want to send with OscMessage whatever is inside the displayinformation, because everytime i change the selection there is another name… I dont want to send one specific name, i want everytime i choose selection 1 to send the name John, everytime i choose the selection 2 to send the name Melanie(etc…)
One more question based on these:
after this procedure i want to take only the value of age and make an if statement inside draw() with the value of age but i don’t know how…
Because in the example above i declared as
String thisOne = “”;
both name and age and if i write into draw() for example if info<40 (i mean if age<40) there is an error about : The operator <= is undefined for the argument type(s) String, int