The cake was a lie

So, I’m just learning OpenSCAD when Tony Buser leaves this comment:

This should be in the next version I believe, see: http://gitorious.org/openscad/openscad/commit/d479fca855688c92f4a9f72f4ec18d655c3b351d

Also, you can set variables on the command line like this:
http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_OpenSCAD_in_a_command_line_environment So you could set a variable to a random value in a shell script too.

Unfortunately, since variables aren’t really variable in openscad, it’s often easier to write code in another language that writes out openscad code. :(

Okay, what the hell.  “Variables aren’t really variables”?  What does that mean?  Yes, yes, OpenSCAD is written using a keyboard, but not really a keyboard.  T, are you just messing with me or what?  How the heck am I supposed to learn this language with this kind of nonsense?!

Amusingly, Tony is the second person to mention that sometimes it’s easier to use another language to write OpenSCAD.  Kidding aside, I kinda get that.  I use PHP to write custom javascript and MySQL all the time, since I sometimes have need for more dynamic-ness than those languages can accommodate. 1

  1. And, as we all know, I’m ever so dynamic []

7 thoughts on “The cake was a lie

  1. The variables are not real variables because they can’t have different values at different places in the script (no increment/decrement, etc.).

    I totally get the part about MySQL, but if you don’t think javascript is dynamic enough, you’re doing it wrong.

  2. @whosawhatsis:
    (1) What happens in OpenSCAD if I define R as 12 at one point, draw a sphere, then redefine it as 10 and draw a cylinder?
    (2) There are programming applications that warrant generating dynamic JS from PHP, especially when you’re dealing with highly dynamic inputs and an AJAX/PHP/MySQL response system. Rather than writing some JS that deals with every possible scenario, I’d rather have some PHP that cranks it out on the fly. Or, imagine JS that uses certain inputs that can only be obtained from the server and not the user.

  3. Setting variables in the javascript from PHP is acceptable. That includes arrays and objects (which in Javascript, are the same thing). Anything further is just wrong. The actual javascript code should not only be static but be in a file that can be cached separately.

  4. the cake is sometimes a lie:

    p=10;
    echo( p);
    assign(p=20)
    echo (p);
    echo(p);

    gives
    ECHO: 10
    ECHO: 20
    ECHO: 10

Comments are closed.