discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

How come Text is undefined?

BR
Bob Roos
Mon, Apr 24, 2023 1:14 PM

Hello OpenSCAD,

module Tags(type,holes){
if (type==1) {
Base = 1;
Text = 0;
echo(concat("type=1, Text=",Text));
}
else {
Base = 0;
Text = 1;
echo(concat("type=0, Text=",Text));
}
Hole = holes;
echo(Text);
}

Tags(1,0);
Tags(0,1);

--
Best regards,
Bob                          mailto:roosbob@wybatap.com

Hello OpenSCAD, module Tags(type,holes){ if (type==1) { Base = 1; Text = 0; echo(concat("type=1, Text=",Text)); } else { Base = 0; Text = 1; echo(concat("type=0, Text=",Text)); } Hole = holes; echo(Text); } Tags(1,0); Tags(0,1); -- Best regards, Bob mailto:roosbob@wybatap.com
WH
Will Hardiman
Mon, Apr 24, 2023 1:25 PM

Probably because your module definition does not include it. Try

module Tags(type, holes, Text){
... (same code as before)
}
Tags(1,0,"Hello World");

You also probably want to change the echo line because it doesn't output
the whole echo onto a single line. But I don't know how to fix it.

Cheers,
Will

On Mon, 24 Apr 2023 at 14:15, Bob Roos roosbob@wybatap.com wrote:

Hello OpenSCAD,

module Tags(type,holes){
if (type==1) {
Base = 1;
Text = 0;
echo(concat("type=1, Text=",Text));
}
else {
Base = 0;
Text = 1;
echo(concat("type=0, Text=",Text));
}
Hole = holes;
echo(Text);
}

Tags(1,0);
Tags(0,1);

--
Best regards,
Bob                          mailto:roosbob@wybatap.com


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Probably because your module definition does not include it. Try module Tags(type, holes, Text){ ... (same code as before) } Tags(1,0,"Hello World"); You also probably want to change the echo line because it doesn't output the whole echo onto a single line. But I don't know how to fix it. Cheers, Will On Mon, 24 Apr 2023 at 14:15, Bob Roos <roosbob@wybatap.com> wrote: > Hello OpenSCAD, > > > module Tags(type,holes){ > if (type==1) { > Base = 1; > Text = 0; > echo(concat("type=1, Text=",Text)); > } > else { > Base = 0; > Text = 1; > echo(concat("type=0, Text=",Text)); > } > Hole = holes; > echo(Text); > } > > Tags(1,0); > Tags(0,1); > > -- > Best regards, > Bob mailto:roosbob@wybatap.com > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
LM
Leonard Martin Struttmann
Mon, Apr 24, 2023 1:41 PM

As I understand it, the definitions of Text are bounded by the {} that
contain them.

Variables are only defined within the {} that contain them.

On Mon, Apr 24, 2023 at 8:15 AM Bob Roos roosbob@wybatap.com wrote:

Hello OpenSCAD,

module Tags(type,holes){
if (type==1) {
Base = 1;
Text = 0;
echo(concat("type=1, Text=",Text));
}
else {
Base = 0;
Text = 1;
echo(concat("type=0, Text=",Text));
}
Hole = holes;
echo(Text);
}

Tags(1,0);
Tags(0,1);

--
Best regards,
Bob                          mailto:roosbob@wybatap.com


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

As I understand it, the definitions of Text are bounded by the {} that contain them. Variables are only defined within the {} that contain them. On Mon, Apr 24, 2023 at 8:15 AM Bob Roos <roosbob@wybatap.com> wrote: > Hello OpenSCAD, > > > module Tags(type,holes){ > if (type==1) { > Base = 1; > Text = 0; > echo(concat("type=1, Text=",Text)); > } > else { > Base = 0; > Text = 1; > echo(concat("type=0, Text=",Text)); > } > Hole = holes; > echo(Text); > } > > Tags(1,0); > Tags(0,1); > > -- > Best regards, > Bob mailto:roosbob@wybatap.com > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
LM
Leonard Martin Struttmann
Mon, Apr 24, 2023 1:48 PM

I think that you could do this:

module Tags(type,holes){
Base = (type==1)? 1 : 0;
Text = (type==1)? 0 : 1;
echo("type=",type,"Text=",Text);

Hole = holes;
echo(Text);
}

On Mon, Apr 24, 2023 at 8:41 AM Leonard Martin Struttmann <
lenstruttmann@gmail.com> wrote:

As I understand it, the definitions of Text are bounded by the {} that
contain them.

Variables are only defined within the {} that contain them.

On Mon, Apr 24, 2023 at 8:15 AM Bob Roos roosbob@wybatap.com wrote:

Hello OpenSCAD,

module Tags(type,holes){
if (type==1) {
Base = 1;
Text = 0;
echo(concat("type=1, Text=",Text));
}
else {
Base = 0;
Text = 1;
echo(concat("type=0, Text=",Text));
}
Hole = holes;
echo(Text);
}

Tags(1,0);
Tags(0,1);

--
Best regards,
Bob                          mailto:roosbob@wybatap.com


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I think that you could do this: module Tags(type,holes){ Base = (type==1)? 1 : 0; Text = (type==1)? 0 : 1; echo("type=",type,"Text=",Text); Hole = holes; echo(Text); } On Mon, Apr 24, 2023 at 8:41 AM Leonard Martin Struttmann < lenstruttmann@gmail.com> wrote: > As I understand it, the definitions of Text are bounded by the {} that > contain them. > > Variables are only defined within the {} that contain them. > > On Mon, Apr 24, 2023 at 8:15 AM Bob Roos <roosbob@wybatap.com> wrote: > >> Hello OpenSCAD, >> >> >> module Tags(type,holes){ >> if (type==1) { >> Base = 1; >> Text = 0; >> echo(concat("type=1, Text=",Text)); >> } >> else { >> Base = 0; >> Text = 1; >> echo(concat("type=0, Text=",Text)); >> } >> Hole = holes; >> echo(Text); >> } >> >> Tags(1,0); >> Tags(0,1); >> >> -- >> Best regards, >> Bob mailto:roosbob@wybatap.com >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >
RW
Rogier Wolff
Mon, Apr 24, 2023 1:53 PM

This doesn't work in openscad. The scope of the "Base" variable I've
tagged with "(*)" is the three lines of its block inside the if.

There is a second Base variable that also has three lines of scope, but
three different lines.

You meant:
module Tags (type, holes)
{
Base = type?1:0;
Text = type?0:1;
...
}

(I've made this mistake less than 2 weeks ago, so it is still fresh).

Roger. 

On Mon, Apr 24, 2023 at 09:14:33AM -0400, Bob Roos wrote:

Hello OpenSCAD,

module Tags(type,holes){
if (type==1) {
Base = 1;  (*)
Text = 0;
echo(concat("type=1, Text=",Text));
}
else {
Base = 0;
Text = 1;
echo(concat("type=0, Text=",Text));
}
Hole = holes;
echo(Text);
}

Tags(1,0);
Tags(0,1);

--
Best regards,
Bob                          mailto:roosbob@wybatap.com


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
f equals m times a. When your f is steady, and your m is going down
your a is going up.  -- Chris Hadfield about flying up the space shuttle.

This doesn't work in openscad. The scope of the "Base" variable I've tagged with "(*)" is the three lines of its block inside the if. There is a second Base variable that also has three lines of scope, but three different lines. You meant: module Tags (type, holes) { Base = type?1:0; Text = type?0:1; ... } (I've made this mistake less than 2 weeks ago, so it is still fresh). Roger. On Mon, Apr 24, 2023 at 09:14:33AM -0400, Bob Roos wrote: > Hello OpenSCAD, > > > module Tags(type,holes){ > if (type==1) { > Base = 1; (*) > Text = 0; > echo(concat("type=1, Text=",Text)); > } > else { > Base = 0; > Text = 1; > echo(concat("type=0, Text=",Text)); > } > Hole = holes; > echo(Text); > } > > Tags(1,0); > Tags(0,1); > > -- > Best regards, > Bob mailto:roosbob@wybatap.com > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org -- ** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 ** ** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 ** f equals m times a. When your f is steady, and your m is going down your a is going up. -- Chris Hadfield about flying up the space shuttle.
BR
Bob Roos
Mon, Apr 24, 2023 2:49 PM

Hi Rogier,

Yes, that is exactly what I meant to do.  :)  I did not know about that form of testing a boolean.

Thank you

Monday, April 24, 2023, 9:53:46 AM, you wrote:

This doesn't work in openscad. The scope of the "Base" variable I've
tagged with "(*)" is the three lines of its block inside the if.

There is a second Base variable that also has three lines of scope, but
three different lines.

You meant:
module Tags (type, holes)
{
Base = type?1:0;
Text = type?0:1;
...
}

(I've made this mistake less than 2 weeks ago, so it is still fresh).

     Roger. 

On Mon, Apr 24, 2023 at 09:14:33AM -0400, Bob Roos wrote:

Hello OpenSCAD,

module Tags(type,holes){
if (type==1) {
Base = 1;  (*)
Text = 0;
echo(concat("type=1, Text=",Text));
}
else {
Base = 0;
Text = 1;
echo(concat("type=0, Text=",Text));
}
Hole = holes;
echo(Text);
}

Tags(1,0);
Tags(0,1);

--
Best regards,
Bob                          mailto:roosbob@wybatap.com


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

--
have Fun,
Bob                          mailto:roosbob@wybatap.com

Hi Rogier, Yes, that is exactly what I meant to do. :) I did not know about that form of testing a boolean. Thank you Monday, April 24, 2023, 9:53:46 AM, you wrote: > This doesn't work in openscad. The scope of the "Base" variable I've > tagged with "(*)" is the three lines of its block inside the if. > There is a second Base variable that also has three lines of scope, but > three different lines. > You meant: > module Tags (type, holes) > { > Base = type?1:0; > Text = type?0:1; > ... > } > (I've made this mistake less than 2 weeks ago, so it is still fresh). > Roger. > On Mon, Apr 24, 2023 at 09:14:33AM -0400, Bob Roos wrote: >> Hello OpenSCAD, >> >> >> module Tags(type,holes){ >> if (type==1) { >> Base = 1; (*) >> Text = 0; >> echo(concat("type=1, Text=",Text)); >> } >> else { >> Base = 0; >> Text = 1; >> echo(concat("type=0, Text=",Text)); >> } >> Hole = holes; >> echo(Text); >> } >> >> Tags(1,0); >> Tags(0,1); >> >> -- >> Best regards, >> Bob mailto:roosbob@wybatap.com >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org -- have Fun, Bob mailto:roosbob@wybatap.com