1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog

Strange Error: NSInvalidArgumentException

Posted by Fred on Sep 07, 2007

I'm getting a strange error ("open Console" or "Terminate" style):

ValueError: NSInvalidArgumentException - *** -[NSBigMutableString replaceCharactersInRange:withString:]: nil argument
This is from this really simple program:
size(640,480)
 
def drawBox():
    """Creates a Box on the Screen"""
    nofill()
    stroke(0)
    rect(20, 20, 200, 200)
    fill(0)
    text(getText(1), 10, 100)
    pass
 
def getText(type):
    tmp = random()
    if type == 1:
        if tmp <= 0.5:
            return "Word1"
        if tmp >= 0.6:
            return "Word2"
 
drawBox()
----------------------------------------------------

What's wrong?


 
Posted by Fred on Sep 07, 2007

the error seems to be cut off for some reason, here it is in it's full glory:
ValueError: NSInvalidArgumentException - *** -[NSBigMutableString replaceCharactersInRange:withString:]: nil argument



Posted by Tom De Smedt on Sep 08, 2007

There's a logical error in getText(): if tmp is between 0.5 and 0.6 no string (nil) is returned to the text() command.

You probably mean:

if tmp <= 0.5: return "Word1"
if tmp >= 0.5: return "Word2"



Posted by Fred on Sep 10, 2007

I am embarrassed (to say the least). Big thanks for helping out!