discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Beginner Confuse

S
SNT
Mon, May 25, 2020 3:21 PM

Hello together,

I'm a beginner in OpenSad and I'm really confused about the result of this
simple example:

Code:
Size=3;
if (5>2) {Size=6; echo("Size=",Size);}
echo("Size=",Size);

Result:
ECHO: "Size=", 6
ECHO: "Size=", 3

Why is the latest echo 3 and not 6? It seems to me that in 'if' condition
variables cannot be set.

Best regards and thank you in advane for your help!

Sven


I'm using OpenScad Version 2019.05

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

Hello together, I'm a beginner in OpenSad and I'm really confused about the result of this simple example: Code: Size=3; if (5>2) {Size=6; echo("Size=",Size);} echo("Size=",Size); Result: ECHO: "Size=", 6 ECHO: "Size=", 3 Why is the latest echo 3 and not 6? It seems to me that in 'if' condition variables cannot be set. Best regards and thank you in advane for your help! Sven ----- I'm using OpenScad Version 2019.05 -- Sent from: http://forum.openscad.org/
RP
Ronaldo Persiano
Mon, May 25, 2020 4:12 PM

I suggest that you read
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Scope_of_variables
and
after that bring your doubts here. I will be glad to answer them.

Em seg., 25 de mai. de 2020 às 16:22, SNT sven.sylla@freenet.de escreveu:

Hello together,

I'm a beginner in OpenSad and I'm really confused about the result of this
simple example:

Code:
Size=3;
if (5>2) {Size=6; echo("Size=",Size);}
echo("Size=",Size);

Result:
ECHO: "Size=", 6
ECHO: "Size=", 3

Why is the latest echo 3 and not 6? It seems to me that in 'if' condition
variables cannot be set.

Best regards and thank you in advane for your help!

Sven


I'm using OpenScad Version 2019.05

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


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

I suggest that you read https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Scope_of_variables and after that bring your doubts here. I will be glad to answer them. Em seg., 25 de mai. de 2020 às 16:22, SNT <sven.sylla@freenet.de> escreveu: > Hello together, > > I'm a beginner in OpenSad and I'm really confused about the result of this > simple example: > > Code: > Size=3; > if (5>2) {Size=6; echo("Size=",Size);} > echo("Size=",Size); > > Result: > ECHO: "Size=", 6 > ECHO: "Size=", 3 > > Why is the latest echo 3 and not 6? It seems to me that in 'if' condition > variables cannot be set. > > Best regards and thank you in advane for your help! > > Sven > > > > > > ----- > I'm using OpenScad Version 2019.05 > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
NH
nop head
Mon, May 25, 2020 4:28 PM

No the Size you define inside braces is a different version and does not
last outside the braces.

Use something like this.

Size = 5 > 2 ? 6 : 3;

echo(Size);

On Mon, 25 May 2020 at 16:22, SNT sven.sylla@freenet.de wrote:

Hello together,

I'm a beginner in OpenSad and I'm really confused about the result of this
simple example:

Code:
Size=3;
if (5>2) {Size=6; echo("Size=",Size);}
echo("Size=",Size);

Result:
ECHO: "Size=", 6
ECHO: "Size=", 3

Why is the latest echo 3 and not 6? It seems to me that in 'if' condition
variables cannot be set.

Best regards and thank you in advane for your help!

Sven


I'm using OpenScad Version 2019.05

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


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

No the Size you define inside braces is a different version and does not last outside the braces. Use something like this. Size = 5 > 2 ? 6 : 3; echo(Size); On Mon, 25 May 2020 at 16:22, SNT <sven.sylla@freenet.de> wrote: > Hello together, > > I'm a beginner in OpenSad and I'm really confused about the result of this > simple example: > > Code: > Size=3; > if (5>2) {Size=6; echo("Size=",Size);} > echo("Size=",Size); > > Result: > ECHO: "Size=", 6 > ECHO: "Size=", 3 > > Why is the latest echo 3 and not 6? It seems to me that in 'if' condition > variables cannot be set. > > Best regards and thank you in advane for your help! > > Sven > > > > > > ----- > I'm using OpenScad Version 2019.05 > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
SS
sven.sylla@freenet.de
Mon, May 25, 2020 5:23 PM

Thank you pretty much Ronaldo!

I didn’t read this topic so far. Now It‘s clear to me and I can proceed!

Best regards Sve (SNT)

Von: Discuss discuss-bounces@lists.openscad.org Im Auftrag von Ronaldo Persiano
Gesendet: Montag, 25. Mai 2020 18:13
An: OpenSCAD general discussion discuss@lists.openscad.org
Betreff: Re: [OpenSCAD] Beginner Confuse

I suggest that you read https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Scope_of_variables and after that bring your doubts here. I will be glad to answer them.

Em seg., 25 de mai. de 2020 às 16:22, SNT <sven.sylla@freenet.de mailto:sven.sylla@freenet.de > escreveu:

Hello together,

I'm a beginner in OpenSad and I'm really confused about the result of this
simple example:

Code:
Size=3;
if (5>2) {Size=6; echo("Size=",Size);}
echo("Size=",Size);

Result:
ECHO: "Size=", 6
ECHO: "Size=", 3

Why is the latest echo 3 and not 6? It seems to me that in 'if' condition
variables cannot be set.

Best regards and thank you in advane for your help!

Sven


I'm using OpenScad Version 2019.05

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


OpenSCAD mailing list
Discuss@lists.openscad.org mailto:Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Thank you pretty much Ronaldo! I didn’t read this topic so far. Now It‘s clear to me and I can proceed! Best regards Sve (SNT) Von: Discuss <discuss-bounces@lists.openscad.org> Im Auftrag von Ronaldo Persiano Gesendet: Montag, 25. Mai 2020 18:13 An: OpenSCAD general discussion <discuss@lists.openscad.org> Betreff: Re: [OpenSCAD] Beginner Confuse I suggest that you read https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General#Scope_of_variables and after that bring your doubts here. I will be glad to answer them. Em seg., 25 de mai. de 2020 às 16:22, SNT <sven.sylla@freenet.de <mailto:sven.sylla@freenet.de> > escreveu: Hello together, I'm a beginner in OpenSad and I'm really confused about the result of this simple example: Code: Size=3; if (5>2) {Size=6; echo("Size=",Size);} echo("Size=",Size); Result: ECHO: "Size=", 6 ECHO: "Size=", 3 Why is the latest echo 3 and not 6? It seems to me that in 'if' condition variables cannot be set. Best regards and thank you in advane for your help! Sven ----- I'm using OpenScad Version 2019.05 -- Sent from: http://forum.openscad.org/ _______________________________________________ OpenSCAD mailing list Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
JW
Jan Wieck
Mon, May 25, 2020 7:56 PM

This is a behavior that seems to surprise a lot of people new to OpenSCAD.
The language looks like a procedural language (something like C or Java),
but it isn't. Once you realize that these aren't statements, that are
executed one after another, the issue makes more sense.

The best explanation I have found is the one from kevfquinn in this thread:
https://www.thingiverse.com/groups/openscad/forums/general/topic:31166

Regards, Jan

On Mon, May 25, 2020 at 12:30 PM nop head nop.head@gmail.com wrote:

No the Size you define inside braces is a different version and does not
last outside the braces.

Use something like this.

Size = 5 > 2 ? 6 : 3;

echo(Size);

On Mon, 25 May 2020 at 16:22, SNT sven.sylla@freenet.de wrote:

Hello together,

I'm a beginner in OpenSad and I'm really confused about the result of this
simple example:

Code:
Size=3;
if (5>2) {Size=6; echo("Size=",Size);}
echo("Size=",Size);

Result:
ECHO: "Size=", 6
ECHO: "Size=", 3

Why is the latest echo 3 and not 6? It seems to me that in 'if' condition
variables cannot be set.

Best regards and thank you in advane for your help!

Sven


I'm using OpenScad Version 2019.05

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


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

--
Jan Wieck
Principal Database Engineer

This is a behavior that seems to surprise a lot of people new to OpenSCAD. The language looks like a procedural language (something like C or Java), but it isn't. Once you realize that these aren't statements, that are executed one after another, the issue makes more sense. The best explanation I have found is the one from kevfquinn in this thread: https://www.thingiverse.com/groups/openscad/forums/general/topic:31166 Regards, Jan On Mon, May 25, 2020 at 12:30 PM nop head <nop.head@gmail.com> wrote: > No the Size you define inside braces is a different version and does not > last outside the braces. > > Use something like this. > > Size = 5 > 2 ? 6 : 3; > > echo(Size); > > > On Mon, 25 May 2020 at 16:22, SNT <sven.sylla@freenet.de> wrote: > >> Hello together, >> >> I'm a beginner in OpenSad and I'm really confused about the result of this >> simple example: >> >> Code: >> Size=3; >> if (5>2) {Size=6; echo("Size=",Size);} >> echo("Size=",Size); >> >> Result: >> ECHO: "Size=", 6 >> ECHO: "Size=", 3 >> >> Why is the latest echo 3 and not 6? It seems to me that in 'if' condition >> variables cannot be set. >> >> Best regards and thank you in advane for your help! >> >> Sven >> >> >> >> >> >> ----- >> I'm using OpenScad Version 2019.05 >> -- >> Sent from: http://forum.openscad.org/ >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > -- Jan Wieck Principal Database Engineer
SS
Sven Sylla
Tue, May 26, 2020 4:16 PM

Hello together,

Actually I use the ? symbol from 'nop head's suggestion  and i'm feeling pretty much comfortable to this very short code implemenation. I have been working since last year on OpenScad and for my application its the very best tool for my 3D objects.
After some challenges with 'too long rendering time' ( obviously a typical beginner argument), mainly based on lots of extrude of dxf file commands, I easily fixed the time problem by closing the lines in the dxf file and the use of $fa instead of $fn. In the meanwhile I feel pretty much fine and for me its not a problem to wait one or two hours on the rendering. Thank you very  much again for the support I got in this forum!

Greetings from Sven (SNT)

Am 25.05.2020 um 21:56 schrieb Jan Wieck jan@wi3ck.info:

This is a behavior that seems to surprise a lot of people new to OpenSCAD. The language looks like a procedural language (something like C or Java), but it isn't. Once you realize that these aren't statements, that are executed one after another, the issue makes more sense.

The best explanation I have found is the one from kevfquinn in this thread: https://www.thingiverse.com/groups/openscad/forums/general/topic:31166

Regards, Jan

On Mon, May 25, 2020 at 12:30 PM nop head nop.head@gmail.com wrote:
No the Size you define inside braces is a different version and does not last outside the braces.

Use something like this.

Size = 5 > 2 ? 6 : 3;

echo(Size);

On Mon, 25 May 2020 at 16:22, SNT sven.sylla@freenet.de wrote:
Hello together,

I'm a beginner in OpenSad and I'm really confused about the result of this
simple example:

Code:
Size=3;
if (5>2) {Size=6; echo("Size=",Size);}
echo("Size=",Size);

Result:
ECHO: "Size=", 6
ECHO: "Size=", 3

Why is the latest echo 3 and not 6? It seems to me that in 'if' condition
variables cannot be set.

Best regards and thank you in advane for your help!

Sven


I'm using OpenScad Version 2019.05

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


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

--
Jan Wieck
Principal Database Engineer


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Hello together, Actually I use the ? symbol from 'nop head's suggestion and i'm feeling pretty much comfortable to this very short code implemenation. I have been working since last year on OpenScad and for my application its the very best tool for my 3D objects. After some challenges with 'too long rendering time' ( obviously a typical beginner argument), mainly based on lots of extrude of dxf file commands, I easily fixed the time problem by closing the lines in the dxf file and the use of $fa instead of $fn. In the meanwhile I feel pretty much fine and for me its not a problem to wait one or two hours on the rendering. Thank you very much again for the support I got in this forum! Greetings from Sven (SNT) > Am 25.05.2020 um 21:56 schrieb Jan Wieck <jan@wi3ck.info>: > > This is a behavior that seems to surprise a lot of people new to OpenSCAD. The language looks like a procedural language (something like C or Java), but it isn't. Once you realize that these aren't statements, that are executed one after another, the issue makes more sense. > > The best explanation I have found is the one from kevfquinn in this thread: https://www.thingiverse.com/groups/openscad/forums/general/topic:31166 > > > Regards, Jan > > > >> On Mon, May 25, 2020 at 12:30 PM nop head <nop.head@gmail.com> wrote: >> No the Size you define inside braces is a different version and does not last outside the braces. >> >> Use something like this. >> >> Size = 5 > 2 ? 6 : 3; >> >> echo(Size); >> >> >>> On Mon, 25 May 2020 at 16:22, SNT <sven.sylla@freenet.de> wrote: >>> Hello together, >>> >>> I'm a beginner in OpenSad and I'm really confused about the result of this >>> simple example: >>> >>> Code: >>> Size=3; >>> if (5>2) {Size=6; echo("Size=",Size);} >>> echo("Size=",Size); >>> >>> Result: >>> ECHO: "Size=", 6 >>> ECHO: "Size=", 3 >>> >>> Why is the latest echo 3 and not 6? It seems to me that in 'if' condition >>> variables cannot be set. >>> >>> Best regards and thank you in advane for your help! >>> >>> Sven >>> >>> >>> >>> >>> >>> ----- >>> I'm using OpenScad Version 2019.05 >>> -- >>> Sent from: http://forum.openscad.org/ >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> Discuss@lists.openscad.org >>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > -- > Jan Wieck > Principal Database Engineer > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org