We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi people!
I´m glad to be here, I find the forum really interessting despite that i´m a begginer. Now my question! :)
As I told you guys, I´m begginer and I´m trying to develop an "App" and to try to understand how it works. I would like to build an app to conjugate verbs in german... So, my idea is to type the verb, press enter and get the conjugations of the verb. I have in a .csv file some verbs in order to try that it works. In this moment I just did a brake to type the verb, then I press enter, but I don´t know how to conect it with the info in the table once enter is pressed...
For example, I would like to type the verb "sein", press enter and receive the conjugation:
Ich - bin Du - Bist bla bla bla....
=================================================================
//Verb Conjugation
String myText = "Type here your verb: ";
String input = myText;
PFont font;
void setup() {
size(500,500);
font = createFont("Sans Serif",40);
textFont(font,20);
textAlign(LEFT,CENTER);
}
void draw() {
background(0);
//variable,
text(myText, 30,0, width,height);
}
void keyPressed() {
if (keyCode == BACKSPACE) {
if (myText.length() > 0) {
myText = myText.substring(0, myText.length()-1);
}
}
else if (keyCode == DELETE) {
myText = "";
}
else if (keyCode != SHIFT) {
//guarda la configuracion de la letra tecleada anteriormente
myText = myText + key;
}
if (keyCode == ' ') {
myText = myText.substring(0, myText.length()-1);
myText = myText + '_';}
if (keyCode == ENTER) {
input = myText;
myText = "";
}
String[] lines = loadStrings("100 Verben.csv");
println("there are " + lines.length + " lines");
for (int i = 0 ; i < lines.length; i++) {
println(lines[i]);
}
}
=================================================================
With this code, I can only type the verb without receive the answer, and I can see the list of the verbs in the console.... To be honest I don´t know how to give the next step.... I know that maybe exists a easier way to do it, but im trying to make it myself in order to learn. :D
Sorry in advance for my possible mistakes!
Thanks for your attention!
Cheers!!!!!
Answers
look at loadTable
a Table has a lo of commands you can use
https://www.processing.org/reference/
if you look at your approach, these lines belong into setup:
but without String[] .
Have String[] lines; before setup()
remeber to hit ctrl-t in processing for auto-format
this works without Table:
Please note that myText is not "Type here your verb: " but what is entered by the user.
Also note I had to move the else
if (keyCode == ENTER) {
part up becauseif (keyCode != SHIFT) {
applies to Enter as well so, enter would be added to myText which we don't want. No ENter is checked beforeif (keyCode != SHIFT) {
so it works. Same applies for Space' '
but I didn't change this. Best use if else throughout and not a mixture of if else and if... (meaning this:if (keyCode == ' ') {
starts a new block which I don't recommend, better useelse if (keyCode == ' ') {
and also move it beforeif (keyCode != SHIFT) {
)Also it's er/sie/es in German, not only er (3rd Pers Sing).
Best, Chrisir ;-)
the core with the search is line 43 to 52 where we split each line and compare input to the first component of the line
the entire line is then copied into result which is shown in draw()
of course you need to put line 19 back in as
and replace line 7 with
String[] lines;
Thank you so much for your help! And thanks for your patience with the begginers like me. It is now more clear for me and also the organization is much better now... Despite that I did modify my program as you wrote, and despite that is clear, I can not do it :(
I type any verb from the list, then I press enter but nothing happens... I´m sure that i´m making a small mistake but I can not see it (I have been trying for the past two hours :D ). Have a look:
//
Regarding to er/sie/es in german, you´re totally right! I just want to make that my code works first and then I will modify the table properly :D It is a mixture between learn a new language and learn processing.
;)
It's case sensitive, you need to write Sein not sein
Use ctrl-t please
:D Sorry! forgot it! :D
In line 48 use println (components [0] );
Does it give you sein and haben and so on ?
No, nothing :/ I can see the data in the console, but not in the window when I execute my code... :(
In line 48 use println (components [0] );
Does it give you sein and haben and so on ?
It should.
is the separator really a , comma ?
is the code really as you have posted it?
This works for me:
https://Processing.org/reference/HashMap.html
import static js.window.prompt;
Here comes the 3 sketch files and the ".csv" file used. :-bd
You can see it online going to the link below: :bz
https://OpenProcessing.org/sketch/436121
Any doubts about my sketch version, just ask here in your forum thread: :-B
verben.csv:
Verb_Conjugation.pde:
TableUtils.pde:
window.java:
Wow!!! guys! Thanks a lot for the help. There is a lot of new things for me that I have to digest :) GoToLoop, Your on-line example is awesome!!! That is what I would like to reach... but I´m still trying to make that my code works :D, as soon as I have done my code, I will post it here to share my experience... It will take a while for me! Thanks again!
Don't forget it also works offline in PDE's "Java Mode" too. It is cross-mode! $-)