FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   Things that trip me up
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Things that trip me up  (Read 387 times)
kevinP

Email
Things that trip me up
« on: Jan 26th, 2004, 11:18pm »

Hi all,
 
I almost posted this to software suggestions, because it has tripped me up several times.
 
Say one starts out with something simple like:
Code:

// Displaying
// by REAS <http://www.groupc.net>
// [some lines deleted]  
 
size(200, 200);
BImage a;  // Declare variable "a" of type BImage
a = loadImage("arch.jpg"); // Load the images into the program
 
image(a, width/2, 0, a.width/2, a.height/2);

 
Okay, then one wants to get a little fancier...
Code:

size(200, 200);
BImage a;  // Declare variable "a" of type BImage
a = loadImage("arch.jpg"); // Load the images into the program
 
void loop()
{
  image(a, mouseX - width/4, mouseY - width/4, a.width/2, a.height/2);
}

 
And one gets the error message: "Unexpected token: void"! This really threw me the first couple times. Couldn't Processing kick out an error message that says something like "Attempt to use 'loop()' without 'setup()'"?
 
Because all it takes to make Processing happy is to take those 3 proceeding lines and place them into setup().
 
BTW, I just tried this:
Code:

BImage a;
{
  size(200, 200);
  a = loadImage("arch.jpg"); // Load the images into the program
}
 
void loop()
{
  image(a, mouseX - width/4, mouseY - width/4, a.width/2, a.height/2);
}

 
...with just brackets and it freezes up Processing. Maybe I should have posted this in the other folder...
 
-K
 
(0067 alpha, linux)
 

Kevin Pfeiffer
benelek

35160983516098 WWW Email
Re: Things that trip me up
« Reply #1 on: Jan 27th, 2004, 1:01am »

i can see how this might trip up those who are moving between programming levels the first few times, or even those who begin working at a high complexity and decide to switch modes for some code that's already written. is anyone else being confused by this?
 
with regards to the freezing, that sounds like a bug. I tried it on my win2k machine, and it didn't freeze up - i got the mass of red error garble. it's included below.
 
i think the two birds might be hit with one stone, by catching this kind of error and providing a warning.
 
~jacob
 
 
Code:
java.lang.NullPointerException
 
 at PdeRuntime.start(PdeRuntime.java:345)
 
 at PdeEditor.doRun(PdeEditor.java:801)
 
 at PdeEditorButtons.mouseReleased(PdeEditorButtons.java:418)
 
 at java.awt.Component.processMouseEvent(Unknown Source)
 
 at java.awt.Component.processEvent(Unknown Source)
 
 at java.awt.Container.processEvent(Unknown Source)
 
 at java.awt.Component.dispatchEventImpl(Unknown Source)
 
 at java.awt.Container.dispatchEventImpl(Unknown Source)
 
 at java.awt.Component.dispatchEvent(Unknown Source)
 
 at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
 
 at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
 
 at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
 
 at java.awt.Container.dispatchEventImpl(Unknown Source)
 
 at java.awt.Component.dispatchEvent(Unknown Source)
 
 at java.awt.EventQueue.dispatchEvent(Unknown Source)
 
 at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
 
 at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
 
 at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
 
 at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
 
 at java.awt.EventDispatchThread.run(Unknown Source)
 
fry


WWW
Re: Things that trip me up
« Reply #2 on: Jan 27th, 2004, 4:16am »

the freeze is a bug that's been fixed and will be taken care of in the next release.
 
re: a better error message, that's more difficult than you might think, unfortunately. there isn't a good way to sense that someone has put the wrong type of functions outside a loop in the preprocessor without some smart tweaking.
 
kevinP

Email
Re: Things that trip me up
« Reply #3 on: Jan 27th, 2004, 11:06am »

Perhaps a minimalistic commented default template that opens with a new sketch? Though that spoils the cleanness and lightness.
 
Or maybe the environment page (link is "Help") just needs to be more specific about this.
 
Actually, adding a link that is delivered with all errors might not be bad. If one has no experience with error messages (and I'm used to those of a different language, for example), a general "have you checked this" page might be useful; there one could build up a small list of common reasons...
 
1. unexpected void (or whatever it was)...
  a) using loop() without setup()?
  b) etc.
  c) etc.
 
(Yeah Kevin, great idea, start making a list; tell us when you're done.)  
 
 
 
 
 
 
 
 
 
 
 

Kevin Pfeiffer
fry


WWW
Re: Things that trip me up
« Reply #4 on: Jan 27th, 2004, 12:39pm »

yeah, for some errors, a link would be really useful. unfortunately, this is one that you're likely to get for dozens of different situations. although a combo of the two things you suggest is a good idea.. that 1) we make a better page about the setup/loop/draw syntax, and make that the default, and 2) make that the suggested link when people run into problems with "unexpected token void" messages, since i'm guessing 80% of time it'll be related to program structure.  
 
thought the danger is that when it's not, it's really gonna confuse and frustrate people.
 
Pages: 1 

« Previous topic | Next topic »