discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

assign() module deprecation

JD
Jerry Davis
Thu, Mar 2, 2017 9:57 PM

I have come upon some modules that have the assign() module in them, and I
know that it has been deprecated.

I think I can change statements like this:
assign(a=p/3) with a = p/3 and be fine.

But what about statement blocks, like the following?

if (a == 0) assign($fn=32) {a bunch of statements }

it seems as though $fn = 32 { statements } doesn't work.

--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Openscad developer

The most exciting phrase to hear in science - the one that heralds new
discoveries - is not "Eureka!" but "That's funny...".
- Isaac. Asimov

I have come upon some modules that have the assign() module in them, and I know that it has been deprecated. I think I can change statements like this: assign(a=p/3) with a = p/3 and be fine. But what about statement blocks, like the following? if (a == 0) assign($fn=32) {a bunch of statements } it seems as though $fn = 32 { statements } doesn't work. -- Extra Ham Operator: K7AZJ Registered Linux User: 275424 Raspberry Pi and Openscad developer *The most exciting phrase to hear in science - the one that heralds new discoveries - is not "Eureka!" but "That's funny...".*- Isaac. Asimov
NH
nop head
Thu, Mar 2, 2017 10:27 PM

You can move the assignment into the braces in most cases. E.g.
if (a == 0)  {$fn=32; a bunch of statements }

If you have a new enough version you can use let in place of assign in
cases where braces don't start a new scope.

Or you can replace assign with for as a work around.

if (a == 0) for($fn=32) {a bunch of statements }

On 2 March 2017 at 21:57, Jerry Davis jdawgaz@gmail.com wrote:

I have come upon some modules that have the assign() module in them, and I
know that it has been deprecated.

I think I can change statements like this:
assign(a=p/3) with a = p/3 and be fine.

But what about statement blocks, like the following?

if (a == 0) assign($fn=32) {a bunch of statements }

it seems as though $fn = 32 { statements } doesn't work.

--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Openscad developer

The most exciting phrase to hear in science - the one that heralds new
discoveries - is not "Eureka!" but "That's funny...".
- Isaac. Asimov


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

You can move the assignment into the braces in most cases. E.g. if (a == 0) {$fn=32; a bunch of statements } If you have a new enough version you can use let in place of assign in cases where braces don't start a new scope. Or you can replace assign with for as a work around. if (a == 0) for($fn=32) {a bunch of statements } On 2 March 2017 at 21:57, Jerry Davis <jdawgaz@gmail.com> wrote: > I have come upon some modules that have the assign() module in them, and I > know that it has been deprecated. > > I think I can change statements like this: > assign(a=p/3) with a = p/3 and be fine. > > But what about statement blocks, like the following? > > if (a == 0) assign($fn=32) {a bunch of statements } > > it seems as though $fn = 32 { statements } doesn't work. > > > > > -- > Extra Ham Operator: K7AZJ > Registered Linux User: 275424 > Raspberry Pi and Openscad developer > > > *The most exciting phrase to hear in science - the one that heralds new > discoveries - is not "Eureka!" but "That's funny...".*- Isaac. Asimov > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >