[OpenSCAD] test if variable is defined

nop head nop.head at gmail.com
Mon Jun 18 21:53:33 CEST 2012

It only seems to work properly with function arguments.

With ordinary variables you get a warning which says "WARNING: Ignoring
unknown variable 'fred'." so you don't gain anything testing it.

I would love a way of defining a default value for a variable and being
able to override it on the command line. The documentation implies it can
be done but it doesn't work.

On 18 June 2012 08:28, Giles Bathgate <giles.bathgate at gmail.com> wrote:

> On 17 June 2012 22:42, Johannes Reinhardt <jreinhardt at ist-dein-freund.de>
> wrote:
> > function defined(a) = str(a) != "undef";
> You should be able to simply write this as:
>    function defined(a) = a != undef;
> Unfortunately there is a bug in openscad so that this doesn't work
> correctly! The following test highlights the problem:
>    if(undef==undef) echo("Should work!");
>    if(undef!=undef) echo("Broken!");
> Regards
> Giles
> _______________________________________________
> OpenSCAD mailing list
> OpenSCAD at rocklinux.org
> http://rocklinux.net/mailman/listinfo/openscad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rocklinux.net/pipermail/openscad/attachments/20120618/3ed97773/attachment.html

More information about the OpenSCAD mailing list