We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I have written the following function, which formats text stored in a field of Strings (Textfeld) and stores the result in a new field (Textzeilen). It works fine in Processing, but once I try to execute it in a browser (using processing.js), it crashes with the error message "SyntaxError: missing ) after argument list".
void ladeText(String datei)
{
Textfeld = loadStrings(datei);
Textzeilen = new String[2000];
int i = 0, j = 0, k = 0;
int breite = (int)(xt2-xt1-50);
textFont(atari, 18);
Textzeilen[0] = new String();
textAnzMax = 0;
do
{
char c = Textfeld[i].charAt(j);
if(textWidth(Textzeilen[k] + c) < breite)
{
Textzeilen[k] += c;
j++;
}
else
{
int l = 0;
while((int)Textfeld[i].charAt(j) != (int)' ') {j--; l++;}
Textzeilen[k] = Textzeilen[k].substring(0, Textzeilen[k].length() - l);
j++;
k++;
Textzeilen[k] = new String();
textAnzMax++;
}
if(j==Textfeld[i].length())
{
if(i>=Textfeld.length-1) break;
j = 0;
do
{
i++;
}
while(Textfeld[i].length() == 0);
k++;
Textzeilen[k] = new String();
k++;
Textzeilen[k] = new String();
textAnzMax+=2;
}
//if(k>=Textzeilen.length) Textzeilen = (String[])expand(Textzeilen);
}
while(true);
}
I strongly suspect it has something to do with the "char" datatype which doesn't exist in JS.