redim

Just starting out? Need help? Post your questions and find answers here.
ppnl
User
User
Posts: 33
Joined: Thu Oct 13, 2011 8:08 am

redim

Post by ppnl »

Does redim clear the array?

I ran the following code:

Code: Select all

Dim parr(10)
OpenConsole() 
For i=0 To 10
  parr(i)=i
Next

For i=0 To 10
  PrintN(Str(parr(i)))
Next

PrintN("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")

ReDim parr(10)
For i=0 To 10
  PrintN(Str(parr(i)))
Next
Input()
CloseConsole()
It did not clear the array. But an online search result claimed that it does and that you need to use the "Preserve" keyword to keep the data. Yet the purebasic help makes no mention of this.

It may be that the problem is that I'm using an old version (6.00) but I'm not sure how to upgrade. I seem to remember that there was a separate link for licensed versions but that was years ago and I cannot find it.
User avatar
Demivec
Addict
Addict
Posts: 4274
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: redim

Post by Demivec »

ppnl wrote: Sun Sep 28, 2025 2:47 am Does redim clear the array?

[*code snipped*]

It did not clear the array. But an online search result claimed that it does and that you need to use the "Preserve" keyword to keep the data. Yet the purebasic help makes no mention of this.
If you had instead searched the help file you would have found a factual answer instead of that fiction created by a fake intelligence algorithm.

Here's a link to the help file for Dim and ReDim: https://www.purebasic.com/documentation/reference/dim.html
It may be that the problem is that I'm using an old version (6.00) but I'm not sure how to upgrade. I seem to remember that there was a separate link for licensed versions but that was years ago and I cannot find it.
You have to login to the PureBasic website and download an updated version. Just click the 'Home' button on the forum to access the website.
ppnl
User
User
Posts: 33
Joined: Thu Oct 13, 2011 8:08 am

Re: redim

Post by ppnl »

Yes, thanks. I did find the log in button on the purebasic page. They really should make that more visible. But to be fair that is the standard place to put a log on button. I just wasn't thinking log in.

Yes I was using the AI overview to do fast syntax checking. It is faster and more readable than the Purebasic help files. And because I'm constantly switching between languages I'm always confusing syntax. But that is the problem with AI. It can very clearly say perfectly reasonable things that are just totally wrong. I suspect that it inappropriately linked Purebasic documentation with some other language. After all there is no actual intelligence there. It is just a complex word trick.

AI is melting reality.
Post Reply