apologies in advance for the geek talk

I spent most of the weekend struggling with the genetic algorithm sketch in Processing. I’d created a version that worked but was coded very inefficiently using strings, so I wanted to rewrite it using arrays. It was galling to find that my attempt at efficiency refused to work at all.

A few hours away from the computer, however, allowed me to think it through afresh, and I saw where I was making a mistake. I hurried home on Monday after work to rewrite the troublesome section in time for the Skype session with Ollie, and voila! It worked. I quickly added the ‘fly‘ class from previous versions, only to find, on calling one of the fly methods, that I received an error message I’ve never seen before: ‘Badly formed character constant’. All that the method does is draw a small rectangle to represent the current position of the fly object.

OK, so I’ve searched my Processing books and Google for an explanation of this, and found some oblique references, but what startled me was that during the Skype session, when I was demonstrating this problem, it worked fine, but as soon as the session was over and I tried again, I got the same error message. I must have changed something somewhere, but I have no idea what. Grrr.

Anyway, after discussing the latest version of the sketch, we agreed that I should refactor the code to use more classes and some ArrayLists. Neither step is completely new for me, but I’m taking tentative steps into unfamiliar territory, especially the idea of using abstract classes that have no real world counterparts like ‘fly‘ and ‘web’. The next week will be busy with other things, so it can be simmering at the back of my mind. If I appear distracted over the next few days, you’ll know why.

Tags:

Tuesday, August 10th, 2010 coding

4 Comments to apologies in advance for the geek talk

  • vozome says:

    I just had a “badly formed character constant” error myself in processing and found your site by googling the infamous message.

    mine happened because I inadvertently copied a file with a pde extension in the folder of a complex project with many files.
    and that extra pde file had a “badly formed character constant” – a ”.

    because I didn’t make any changes to the code I meant to run, I had trouble finding the error, so I thought I’d share if this happens to anyone else.

  • qwertz says:

    you also run in this error if you have smth like:

    String asd = ‘asd’;

    that should, of course be like

    String asd = “asd”;

    hopefully this will help someone somewhen 😉

  • Anthony Hologram says:

    Ha ha just got this myself. It turned out to be a stray ‘ (single quote) character HIDING at the end of a line:

    color c=color(0,1,0);’

    A real stinker to find, since the preprocessor gives no hint as to WHERE the ‘badly formed character constant’ is located!

  • jacob says:

    thank you anthony! you comment just saved me a few hours of frustrating debugging!
    best
    jacob
    (moving to eclipse)

  • Leave a Reply