As far as I know, Purebasic declares and defines variables even if they are not reached directly through conditional code during runtime. The following code demonstrates a situation where this is not the case anymore, leading to a 0-based string variable:
Code: Select all
cycles.i = 0
For i.i = 1 To cycles
s.s + "*"
Next i
Debug @s
Note: The according debug output is "0"!
As a workaround, the following modification of the above code leads to a legit address:
Code: Select all
s.s = ""
cycles.i = 0
For i.i = 1 To cycles
s.s + "*"
Next i
Debug @s
That new behaviour triggers crashes in my projects as I was relying on the original behaviour, because as far as I know, the original behaviour was on purpose.
Go, tell it on the mountains.