We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Unexpected token errors
Page Index Toggle Pages: 1
Unexpected token errors (Read 495 times)
Unexpected token errors
Jan 21st, 2007, 10:50pm
 
I have this code:

import processing.xml.*;
XMLElement settingsxml;
void setup()
{
background(0);
String[] configlines = loadStrings("config.txt");
size(int(configlines[1]), int(configlines[2]));
}
settingsxml = new XMLElement(this, "default.xml");
int numelements = settingsxml.getChildCount();
[...]
void draw()
{
[...]
}

It's supposed to load the main config file, parse an XML file (which will eventually be user-selectable, so you can choose your own settings), but I get the error "unexpected token: settingsxml" on line 9. If the code

settingsxml = new XMLElement(this, "default.xml");
int numelements = settingsxml.getChildCount();

is moved before setup(), it gives an "unexpected token: void" error on line 5. The code works with no parse errors inside setup(), but it can't go there because the variables parsed need to be accessible by the rest of the program.
Any ideas?
Re: Unexpected token errors
Reply #1 - Jan 22nd, 2007, 12:04am
 
Never mind, figured out another way to do it.
Page Index Toggle Pages: 1