Conditionally causing compilation to fail or stop

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

Conditionally causing compilation to fail or stop

Ivo
Is there a way to conditionally cause compilation to stop ?

I have a script where certain combinations of parameters are useless and
i'd like to be able to cause OpenSCAD to somehow stop compilation.
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: Conditionally causing compilation to fail or stop

kintel
Administrator
On 2013-05-19, at 11:25 , Ivo wrote:

> Is there a way to conditionally cause compilation to stop ?
>
No, but perhaps it's an idea to add an assert() function for this purpose?

 -Marius

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: Conditionally causing compilation to fail or stop

Alan Cox
In reply to this post by Ivo
On Sun, 19 May 2013 17:25:26 +0200
Ivo <[hidden email]> wrote:

> Is there a way to conditionally cause compilation to stop ?
>
> I have a script where certain combinations of parameters are useless and
> i'd like to be able to cause OpenSCAD to somehow stop compilation.

Best you can do is something like



        if (parameters valid)
                render_model();
        else
                render_error();

and render a fail logo of some kind
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: Conditionally causing compilation to fail or stop

kintel
Administrator
On 2013-05-19, at 12:09 , Alan Cox wrote:
>
> if (parameters valid)
> render_model();
> else
> render_error();
>
> and render a fail logo of some kind

Hehe, visual error representation is a nice idea - perhaps we should render syntax errors  that way as well :)

Anyway, especially for cmd-line use, I think having an error message (and error return code?) would make sense.

 -Marius

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Ivo
Reply | Threaded
Open this post in threaded view
|

Re: Conditionally causing compilation to fail or stop

Ivo
In reply to this post by Alan Cox
Alan Cox wrote
Best you can do is something like

        if (parameters valid)
                render_model();
        else
                render_error();

and render a fail logo of some kind
Thanks for the tip. I'm going to do this, probably with a validate_params() per <use>d file.

I use nested modules so at some point this is going to cause type tiny 3D printed error objects :)
Reply | Threaded
Open this post in threaded view
|

Re: Conditionally causing compilation to fail or stop

kintel
Administrator
On 2013-05-21, at 11:24 , Ivo wrote:

>
> I use nested modules so at some point this is going to cause type tiny 3D
> printed error objects :)
>
You can, in addition, echo() a fat error message.

 -Marius

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Ivo
Reply | Threaded
Open this post in threaded view
|

Re: Conditionally causing compilation to fail or stop

Ivo
In reply to this post by kintel
kintel wrote
Anyway, especially for cmd-line use, I think having an error message (and error return code?) would make sense.

 -Marius
There is also the issue of cleaning up echo(), maybe these issues can be combined.

Assert would be something like "assert(<condition expression>, <error text>);"

As for cleaning up echo(), i was playing with a way for a run of an .scad file to output the parameters for the next iteration of that .scad file, allowing all sorts of fractally and organic products. Also for controlling the merging generated .stl's. A clean and maybe formatted echo() would be very helpfull.