[OpenSCAD] Incrementing a variable doesn't work as expected.

Peter Falke stempeldergeschichte at googlemail.com
Wed Apr 1 05:00:38 EDT 2015


               pos = pos + inc; // the inc seems to have gone out of scope

This is the problem: this is the last definition for pos, so only this one
is used (pos=0 will be ignored).
And it is undefined, as when the left side is assigned the right side has
no meaning,yet. Its a recursion.

2015-04-01 10:54 GMT+02:00 Peter Falke <stempeldergeschichte at googlemail.com>
:

> You can not reassign variables. Variables in OpenSCAD are constants.
> Please have a look at the manual:
>
> http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language#Variables
>
> 2015-04-01 10:50 GMT+02:00 Peter Falke <
> stempeldergeschichte at googlemail.com>:
>
>> Are ypu using a current version of OpenSCAD? The latest?
>>
>>
>> 2015-04-01 9:44 GMT+02:00 nigeljohnson73 <nigel at nigeljohnson.net>:
>>
>>> For info, here is my recursive position counter that fails:
>>>
>>> function cpos(s, n) = cpos(s,n-1) + (n == -1) ? (0) : ( (s[n]==".") ? 2 :
>>> 4);
>>>
>>> when I use it instead of pos in the x coordinate for example in the dit:
>>>
>>> translate([cpos(s,i)+lu/2,0,0]) cylinder(r=lu/2, h = (id+wt+2)/2);
>>>
>>> it says recursion detected. It's not lying  but the manual says I can do
>>> recursion with the trigraph stuff.
>>>
>>>
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://forum.openscad.org/Incrementing-a-variable-doesn-t-work-as-expected-tp12271p12272.html
>>> Sent from the OpenSCAD mailing list archive at Nabble.com.
>>>
>>> _______________________________________________
>>> OpenSCAD mailing list
>>> Discuss at lists.openscad.org
>>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>>
>>
>>
>>
>> --
>> stempeldergeschichte at googlemail.com <karsten at rohrbach.de>
>>
>> P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
>> Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu
>> schreiben.
>> Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.
>>
>> P.S. In case my e-mail is shorter than you enjoy:
>> I am currently trying short replies instead of no replies at all.
>> Please let me know, if you like to read more.
>>
>> Enjoy!
>>
>
>
>
> --
> stempeldergeschichte at googlemail.com <karsten at rohrbach.de>
>
> P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
> Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu
> schreiben.
> Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.
>
> P.S. In case my e-mail is shorter than you enjoy:
> I am currently trying short replies instead of no replies at all.
> Please let me know, if you like to read more.
>
> Enjoy!
>



-- 
stempeldergeschichte at googlemail.com <karsten at rohrbach.de>

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu
schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20150401/b1b6bb3d/attachment-0002.html>


More information about the Discuss mailing list