Anno domini 2021 Mon, 15 Mar 16:50:59 -0400
Gene Heskett scripsit:
> Greetings all;
>
> I need help in understanding OpenSCAD's version of a variables scope. I
> can assign an $XX variable at the top of a .scad file but it doesn't get
> passed into subsequent constructs inside of {} isolated functions's.
>
> So how is this done in OpenSCAD?
Global variables are visible everywhere. e.g.:
$fn=180;
a=10;
Global variables are hidden by module definitions. Variabes in module
definitions are only visible inside "module":
a=10;
echo(a);
module xxx(a,b) { echo(a); echo(b); }
xxx(99,88);
echo(b);
You can define local variable with "let" - globals are hidden, aso nested "led"
hide variables:
a=10;
let (a=1, b=88) {
echo(a);
echo (b);
let (a=99) {
echo(a);
}
}
echo(a);
echo(b);
Last note: variables are not variabes, they are "write-once-variables". e.g.
this will fail on newer versions od openscad, but will succeed on older
versions (and gixe 2x 99):
a=10;
echo(a);
a=99;
echo(a);
Nik
>
> Thanks all.
>
> Cheers, Gene Heskett
--
Please do not email me anything that you are not comfortable also sharing with
the NSA, CIA ...
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users