discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Should it be possible to reference a variable inside a module when the module is loaded by use?

WF
William F. Adams
Thu, Sep 21, 2023 3:57 AM

Say I have a file with the lines:
use <pygcodepreview.scad>;
generategcode = true;
a = 300;
gcomment(str(a));
and pygcodepreview.scad is loaded from a library directory and contains:
module gcomment(comment) {if (generategcode == true) { echo("(",comment,")");}}
Should that work? If it should, why do I get the error:

Documents/OpenSCAD/libraries/pygcodepreview.scad, line 4

WARNING: Ignoring unknown variable 'generategcode' in file ../Documents/OpenSCAD/libraries/pygcodepreview.scad, line 8
I thought I had used such constructs in the past?
Did something change? Or am I getting this wrong somehow?(I'm using the nightly build: https://files.openscad.org/snapshots/OpenSCAD-2023.09.10-x86-64-Installer.exe )William

Say I have a file with the lines: use <pygcodepreview.scad>; generategcode = true; a = 300; gcomment(str(a)); and pygcodepreview.scad is loaded from a library directory and contains: module gcomment(comment) {if (generategcode == true) { echo("(",comment,")");}} Should that work? If it should, why do I get the error: Documents/OpenSCAD/libraries/pygcodepreview.scad, line 4 WARNING: Ignoring unknown variable 'generategcode' in file ../Documents/OpenSCAD/libraries/pygcodepreview.scad, line 8 I thought I had used such constructs in the past? Did something change? Or am I getting this wrong somehow?(I'm using the nightly build: https://files.openscad.org/snapshots/OpenSCAD-2023.09.10-x86-64-Installer.exe )William