discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] where does "included" code get included? - and effect on the Customizer

K
ken@volksswitch.org
Fri, Jun 15, 2018 5:28 PM

Does a file of included code get inserted in the program where the "include"
statement is placed?  That would affect the scope of variables.

Also, I'm having trouble with variables, defined in included code, showing
up in weird places in the Customizer pane, with weird descriptions.  Anyone
understand how this is expected to work?  Again, if I could accurately
control where code was included, I might be able to control how it shows up
in the customizer.  For example I have an include statement in the
/[Hidden]/ portion of the code but variables in the included code are
still showing up in the Customizer pane.

Thanks,

Ken

Does a file of included code get inserted in the program where the "include" statement is placed? That would affect the scope of variables. Also, I'm having trouble with variables, defined in included code, showing up in weird places in the Customizer pane, with weird descriptions. Anyone understand how this is expected to work? Again, if I could accurately control where code was included, I might be able to control how it shows up in the customizer. For example I have an include statement in the /*[Hidden]*/ portion of the code but variables in the included code are still showing up in the Customizer pane. Thanks, Ken
T
Troberg
Mon, Jun 18, 2018 8:30 AM

You can override variables in the including code.

Example, the code below will show "true":

file: includelibrary.scad

generatepartlist=false;

file: usinglibrary.scad

<include includelibrary.scad>

generatepartlist=true;
echo(generatepartlist);

This is actually pretty neat, and I use it a lot (for example, so I don't
clog up the ouput with part lists when I don't want them).

--
Sent from: http://forum.openscad.org/

You can override variables in the including code. Example, the code below will show "true": file: includelibrary.scad generatepartlist=false; file: usinglibrary.scad <include includelibrary.scad> generatepartlist=true; echo(generatepartlist); This is actually pretty neat, and I use it a lot (for example, so I don't clog up the ouput with part lists when I don't want them). -- Sent from: http://forum.openscad.org/
M
MichaelAtOz
Tue, Jun 19, 2018 1:11 AM

khackbarth wrote

Does a file of included code get inserted in the program where the
"include"
statement is placed?  That would affect the scope of variables.

Yes, include<> just places text effectively inline. So as you say, where it
is include'd needs consideration.
use<> is a bit funny, it sort of wraps the code in a scope level, so
variables are available inside-use'd code, but not the top/outside scope.
$variables can be even stranger.

Also, I'm having trouble with variables, defined in included code, showing
up in weird places in the Customizer pane, with weird descriptions.
Anyone
understand how this is expected to work?  Again, if I could accurately
control where code was included, I might be able to control how it shows
up
in the customizer.  For example I have an include statement in the
/[Hidden]/ portion of the code but variables in the included code are
still showing up in the Customizer pane.

I'm not up to speed on customiser. You probably want to make sure you have
the latest version, some such were fixed.


Admin - PM me if you need anything, or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

Sent from: http://forum.openscad.org/

khackbarth wrote > Does a file of included code get inserted in the program where the > "include" > statement is placed? That would affect the scope of variables. Yes, include<> just places text effectively inline. So as you say, where it is include'd needs consideration. use<> is a bit funny, it sort of wraps the code in a scope level, so variables are available inside-use'd code, but not the top/outside scope. $variables can be even stranger. > Also, I'm having trouble with variables, defined in included code, showing > up in weird places in the Customizer pane, with weird descriptions. > Anyone > understand how this is expected to work? Again, if I could accurately > control where code was included, I might be able to control how it shows > up > in the customizer. For example I have an include statement in the > /*[Hidden]*/ portion of the code but variables in the included code are > still showing up in the Customizer pane. I'm not up to speed on customiser. You probably want to make sure you have the latest version, some such were fixed. ----- Admin - PM me if you need anything, or if I've done something stupid... Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- Sent from: http://forum.openscad.org/