Dim lst(255)
For t = 0 To 100000
i = Random(255)
lst(i) + 1
Next
For t = 0 To 255
Debug lst(t)
sum + lst(t)
Next
Debug "sum (should be 100001):" + Str(sum)
As I said before var+1 in PB replaces var+=1 in other languages which is precompiled to var=var+1 or Array(x)+1 gets Array(x)=Array(x)+1
or lst(Random(255))+1 gets lst(Random(255))=lst(Random(255))+1
RGR
Edited:
A feature I don't want to miss in the future!
.
--------------
Yes, its an Irish Wolfhound.
Height: 107 cm; Weight: 88 kg
And we need Mister CodeProfessor to show us the right way?
I work since 2003 with PB - you joined 2012
I am glad with it 10 years now - you obviously not (see the other feature request thread you just started)
No comment anymore
RGR
--------------
Yes, its an Irish Wolfhound.
Height: 107 cm; Weight: 88 kg
codeprof wrote:But PB is the only programming language I know which is doing it this way.
Others like C,C# won't call Random() twice.
I agree with you it is strange and I never expected for it to work that way from previous experiences with other languages, the documentation IMO is misleading and routinely someone come up with this. Nevertheless the official explanation was it was made so by design, so you just have too keep in mind the way it actually works. At this point I don't think is going to change.