I am pretty new at using contextfree and I have a question:
I am using the following code:
startshape one
var=5
shape one{
var=var - 1
asquare[]
if (var) one[x 0.1 s 0.95]
}
shape asquare{
SQUARE
SQUARE[s 0.95 b 1 ]
}
I want to draw only 5 squares.
I use "var" variable to restrict further drawing of squares.
However the code draws limitless squares.
If I define "var=1" then only one square will be drawn, which is what is expected. That means that the expression "var=var - 1" works once but not again (like in the case of var=5).
Why this is happening? It seems like the variable is only temporalily edited in the "shape one" and then reset to its original value.
ps:(I suspect I am confused about the way the code is executed)
You are declaring a new var variable that is distinct from the global var variable. The local var variable will always be 4. Redeclaring a variable with the same name should probably be an error because it doesn't do what you think it does and what it actually does is not particularly useful.