includes inside if statements?

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

includes inside if statements?

nophead
I tried this:

machine = "sturdy90";

if(machine == "sturdy90")
    include <sturdy_config.scad>
if(machine == "mendel90")
    include <mendel_config.scad>
if(machine == "huxley90")
    include <huxley_config.scad>


Each included file had an echo to show which one was included and then set some variables. The echo printed "sturdy" but the variables were set from the huxley file. Is there anyway to make this work. I want to select which config file is included from the command line.
Reply | Threaded
Open this post in threaded view
|

Re: includes inside if statements?

Kliment Yanev
I worked around this by using an array of arrays of settings and passing the array index on the command line.

On 02/12/2012 11:22 PM, nop head wrote:
I tried this:

machine = "sturdy90";

if(machine == "sturdy90")
    include <sturdy_config.scad>
if(machine == "mendel90")
    include <mendel_config.scad>
if(machine == "huxley90")
    include <huxley_config.scad>


Each included file had an echo to show which one was included and then set some variables. The echo printed "sturdy" but the variables were set from the huxley file. Is there anyway to make this work. I want to select which config file is included from the command line.
_______________________________________________ OpenSCAD mailing list [hidden email] http://rocklinux.net/mailman/listinfo/openscad

Reply | Threaded
Open this post in threaded view
|

Re: includes inside if statements?

nophead
Yes that would work but I like a file of named constants per machine. It is a lot more end user friendly and less error prone. 

I think I will have to make a python script that copies the active config file to a fixed name before calling openscad.


On 12 February 2012 22:24, Kliment Yanev <[hidden email]> wrote:
I worked around this by using an array of arrays of settings and passing the array index on the command line.


On 02/12/2012 11:22 PM, nop head wrote:
I tried this:

machine = "sturdy90";

if(machine == "sturdy90")
    include <sturdy_config.scad>
if(machine == "mendel90")
    include <mendel_config.scad>
if(machine == "huxley90")
    include <huxley_config.scad>


Each included file had an echo to show which one was included and then set some variables. The echo printed "sturdy" but the variables were set from the huxley file. Is there anyway to make this work. I want to select which config file is included from the command line.
_______________________________________________ OpenSCAD mailing list [hidden email] http://rocklinux.net/mailman/listinfo/openscad


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