OpenSCAD two problems and futur documentation openscad and openFoam

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

OpenSCAD two problems and futur documentation openscad and openFoam

Pierre Lecanu Wibee
Hello,

I have two problem?

First problem

It is possible to create a array as
a=1;
b=2;
array=[a,b];


 it is possible to read the values
echo(array[0]);



it is impossible to create a new value in the array as
array[2]=3;




Second problem


Is it possible of crer a function with a condition?

function toto(i)= if (i=0) {return = [0];} else {return = [5];}
echo(toto(3));



I use openscad and openFoam
openscad it's an excellent software

I prepare a documentation to use openscad with openFoam


best regard


--
Cordialement

Pierre Lecanu
@wibee.eu



Reply | Threaded
Open this post in threaded view
|

Re: OpenSCAD two problems and futur documentation openscad and openFoam

Brad Pitcher
The first is not currently possible in OpenSCAD. You cannot assign new values to arrays.

Your second task can be achieved using a C-like tertiary operator: http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Mathematical_Operators

Your example would be:
function toto(i) = (i=0) ? [0] : [5];

Hope that answers your questions!
-Brad


On Fri, Oct 21, 2011 at 8:16 AM, Pierre Lecanu Wibee <[hidden email]> wrote:
Hello,

I have two problem?

First problem

It is possible to create a array as
a=1;
b=2;
array=[a,b];


 it is possible to read the values
echo(array[0]);



it is impossible to create a new value in the array as
array[2]=3;




Second problem


Is it possible of crer a function with a condition?

function toto(i)= if (i=0) {return = [0];} else {return = [5];}
echo(toto(3));



I use openscad and openFoam
openscad it's an excellent software

I prepare a documentation to use openscad with openFoam


best regard


--
Cordialement

Pierre Lecanu
@wibee.eu


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad

Reply | Threaded
Open this post in threaded view
|

Re: OpenSCAD two problems and futur documentation openscad and openFoam

kintel
Administrator
In reply to this post by Pierre Lecanu Wibee
On Oct 21, 2011, at 17:16 PM, Pierre Lecanu Wibee wrote:

> it is impossible to create a new value in the array as
> array[2]=3;
>
At the moment, this is not possible in OpenSCAD.

> Is it possible of crer a function with a condition?
>
> function toto(i)= if (i=0) {return = [0];} else {return = [5];}
>
function toto(i) = (i == 0) ? [0] : [5];

 -Marius


Reply | Threaded
Open this post in threaded view
|

Re: OpenSCAD two problems and futur documentation openscad and openFoam

Brad Pitcher
function toto(i) = (i == 0) ? [0] : [5];

Whoops, yeah I forgot the double ==. Listen to Marius, not me