Hi,
Here I attach screenshot of my processing project. Here I subtract 2 values by putting in my code.
but i want to take those values from keyboard after run the program and showing results in that place.
MY CODE is
float a=12.6;
float b=8.3;
float d;
String E ="";
String F ="";
String G ="";
void setup(){
size(600,300);
}
void draw(){
background(200);
fill(100);
textSize(20);
d = a - b;
String F =“a=”+a;
text(F,30,40);
String G =“b=”+b;
text(G,30,70);
String E =“Result is :” +d;
text(E,30,95);
}
please give me the code for Add or Subtract values from taken keyboard and how to show result.
Have a global String input1; or something, and have keyPressed() add to it.
Use if statements to determine if key is a number, or a key like “S” - if it’s “S”, then switch keyPressed() to adding to String input2 instead using a global boolean variable.
Boss, is it possible give correction by edit my processing code? If same values i can put by keyboard and get results In same appearance. it will be more easy to understand for me.
?? who you are talking to?
if you address a other user you say @kll
so a msg ( or even email ) pops up in my user panel
did you run my code ? with the buttons and windows come up and you can put in numbers
and then that numbers are visible at the buttons and can be used elsewhere in the canvas by text()
if you like THAT you use it and cut it down to 2 float buttons
( deleting much more easy as write again )
and calculate the result and show it in a text line ( like the text(“Z”… )
if i do that for you, you might even understand less.
Not in realtime - as soon as you press “Run”, it’s compiled and values that you “set in stone” will be like that - the only way to change them is by code(which you want), or by re-running the sketch again.
I’m not including different debugging tools Processing offers, because if you’ll start relying on them, these might limit your sketch to being usable only within Processing and only with these tools, which is something best to avoid.
@kll, after editing your code which you were providing me i came to that stage attaching the screenshot here, but I can’t get the result of the sum. Please tell me how I can get the result of the summation.