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
Sent from: http://forum.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
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
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
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
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
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
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
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
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