Discussion:
Interesting namespace error...
Stuart Axon
2009-08-31 04:56:30 UTC
Permalink
If you run this simple example

http://www.multiply.org/notebook/archives/2008/08/processing-and.html

(in filestructure and older branch)


Shoebot complains that 'w' is not in the namespace ('w' is in the code) -- Heres the example code:

sizeheight = 600
sizewidth = 600

def background (w,h):
size(w, h)
fill(.7, .7, .7)
rect(0, 0, w, h)

background(sizewidth, sizeheight)

for i in range(20):
fill(i*40/255.0, i*40/255.0, i*40/255.0)
stroke(i*20/255.0, i*20/255.0, i*20/255.0)
rect(i*40, i*40, 40, 40)
ricardo lafuente
2009-09-03 11:21:10 UTC
Permalink
this happens because of the fancy way we use to get size() information
from a script before running it -- basically looking for it using a
regex (Francesco wrote that IIRC).

The problem is that it only parses the size() line, not the ones before
it, so if size() is called using variable arguments, the whole thing
borks out.

Maybe a hacky solution would be to find the size() line and run
everything before it. But it wouldn't work in this case since size() is
inside a function. Grr...

Or maybe the script could be run once without a canvas to determine
this... maybe having a NullCanvas (which would take bot commands but
output nothing) could be useful for this?
Post by Stuart Axon
If you run this simple example
http://www.multiply.org/notebook/archives/2008/08/processing-and.html
(in filestructure and older branch)
sizeheight = 600
sizewidth = 600
size(w, h)
fill(.7, .7, .7)
rect(0, 0, w, h)
background(sizewidth, sizeheight)
fill(i*40/255.0, i*40/255.0, i*40/255.0)
stroke(i*20/255.0, i*20/255.0, i*20/255.0)
rect(i*40, i*40, 40, 40)
_______________________________________________
Shoebot-devel mailing list
http://lists.tinkerhouse.net/listinfo.cgi/shoebot-devel-tinkerhouse.net
Stuart Axon
2009-09-04 16:36:55 UTC
Permalink
Hm, probably better to support calling size() more than once, start with a
default canvas size then resize it on hitting the first size() call.



----- Original Message ----
From: ricardo lafuente <***@sollec.org>
To: shoebot-devel-***@public.gmane.org
Sent: Thursday, September 3, 2009 12:21:10 PM
Subject: Re: [shoebot-devel] Interesting namespace error...

this happens because of the fancy way we use to get size() information
from a script before running it -- basically looking for it using a
regex (Francesco wrote that IIRC).

The problem is that it only parses the size() line, not the ones before
it, so if size() is called using variable arguments, the whole thing
borks out.

Maybe a hacky solution would be to find the size() line and run
everything before it. But it wouldn't work in this case since size() is
inside a function. Grr...

Or maybe the script could be run once without a canvas to determine
this... maybe having a NullCanvas (which would take bot commands but
output nothing) could be useful for this?
Post by Stuart Axon
If you run this simple example
http://www.multiply.org/notebook/archives/2008/08/processing-and.html
(in filestructure and older branch)
sizeheight = 600
sizewidth = 600
size(w, h)
fill(.7, .7, .7)
rect(0, 0, w, h)
background(sizewidth, sizeheight)
fill(i*40/255.0, i*40/255.0, i*40/255.0)
stroke(i*20/255.0, i*20/255.0, i*20/255.0)
rect(i*40, i*40, 40, 40)
_______________________________________________
Shoebot-devel mailing list
http://lists.tinkerhouse.net/listinfo.cgi/shoebot-devel-tinkerhouse.net
Continue reading on narkive:
Loading...