[OpenSCAD] Parser funnyness

Elmo elmo.mantynen at iki.fi
Fri Mar 25 14:30:36 CET 2011


It complains about not finding "var1".

But good point, the code in MCAD that I thoughr used this trick actually 
only defined a var that shadowed a module parameter with the same name, 
like this:
"""
module t(var1 = 1)
{
   var1 = 0 == 0 ? var1*5 : var1;
   echo(var1);
}
t();
"""

Which works, and is workaround and almost as nice a trick.

Elmo

On 03/25/2011 02:30 PM, Giles Bathgate wrote:
> Well what is the behaviour observed?
> Since openscad doesn't support variables that vary, does
>
>     echo(var1)
>
> Does it give  5*5 = 25?
> Does it give 1*5 = 5?
> or does it do undef*5 = undef?
>
> See: http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General
>
> BTW RapCAD can do this no worries ;)
>
> giles at BP0039:~$ rapcad-build-desktop/rapcad -f test.rcad
> ------Script------
> var1=1;
> var1=((0==0)?(var1*5):var1);
> echo(var1,"\n");
> ----Output----
> 5
>
>
> On 25 March 2011 12:17, Elmo<elmo.mantynen at iki.fi>  wrote:
>> This simple code doesn't work:
>> """
>> var1 = 1;
>> var1 = 0 == 0 ? var1*5 : var1;
>> """
>>
>> this works:
>> """
>> var1 = 1;
>> var2 = 0 == 0 ? var1*5 : var1;
>> """
>>
>> Not impossible to workaround, but annoying.
>>
>> Using latest version from github.
>>
>> Elmo
>> _______________________________________________
>> OpenSCAD mailing list
>> OpenSCAD at rocklinux.org
>> http://rocklinux.net/mailman/listinfo/openscad
>>
> _______________________________________________
> OpenSCAD mailing list
> OpenSCAD at rocklinux.org
> http://rocklinux.net/mailman/listinfo/openscad


More information about the OpenSCAD mailing list