@Fred: Questions about setting array to different address

Everything else that doesn't fall into one of the other PB categories.
User avatar
Hades
Enthusiast
Enthusiast
Posts: 188
Joined: Tue May 17, 2005 8:39 pm

@Fred: Questions about setting array to different address

Post by Hades »

It is possible to set an array to a different address.

Code: Select all

Dim A.l(3,3)
A() = AllocateMemory(128)
- Is this a feature that will work in future too?

- What happens with the original memory area of the array? Is it freed, or should I reset the array to it's original address?


btw.: excellent work with Beta 9, Fred. PB gets better and better... :D
mdp
Enthusiast
Enthusiast
Posts: 115
Joined: Mon Apr 18, 2005 8:28 pm

Post by mdp »

Code: Select all

Dim A.l(8) : A(0)=123
p0 = @A() : Debug p0

A() = AllocateMemory(128) 
p1 = @A() : Debug p1

Debug PeekL(p0)
As you can see, it does not seem to be freed
Nik
Addict
Addict
Posts: 1017
Joined: Fri May 13, 2005 11:45 pm
Location: Germany
Contact:

Post by Nik »

freeing<>filling with zeros
Fred
Administrator
Administrator
Posts: 18351
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

You should not use this trick, as it's not granted to be future proof.
mdp
Enthusiast
Enthusiast
Posts: 115
Joined: Mon Apr 18, 2005 8:28 pm

Post by mdp »

Yes Nik,
It was just a guess based on some results.

Code: Select all

Dim a(10) : Debug @a()
Dim b(10) : Debug @b()
Dim c(10) : Debug @c()
Dim d(10) : Debug @d()
c()=AllocateMemory(10) : Debug @c()
Dim e(10) : Debug @e()              ; @e() still follows @d()

Code: Select all

Dim a(10) : Debug @a()
Dim b(10) : Debug @b()
Dim c(10) : Debug @c()
Dim d(10) : Debug @d()
Dim c(20) : Debug @c()
Dim e(10) : Debug @e()  ; @e() replaced @c()
It meant: "Apparently, you could try"

[edit]
but I see the official answer arrived...
User avatar
Hades
Enthusiast
Enthusiast
Posts: 188
Joined: Tue May 17, 2005 8:39 pm

Post by Hades »

@Fred

Thank you for your answer, but it's a shame it isn't future proof.

Sure, Pointers are always possible, but at the moment I'm indexing from one array in memory into another array in memory, and that's a bit ugly with Pointers, at least for development.


I'm writing some fairly complex code here and have already some trouble keeping track what's going on. :roll: So I try to make everything as simple as possible.
Fred
Administrator
Administrator
Posts: 18351
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

It's not a shame, you are dealing with PB internals which are not documented, what did you expect ?
chen
Enthusiast
Enthusiast
Posts: 338
Joined: Fri Dec 23, 2005 2:20 pm
Location: Quebec, Canada
Contact:

Post by chen »

Fred wrote:you are dealing with PB internals which are not documented, what did you expect ?
What does this mean?

that knowledge is not for us... or we are going to have soon that documentation...
:roll:
maw

Post by maw »

I assume Fred means exactly what he said. PB internals are not documented, so that knowledge is not for us. And I bet they wont be documented in the foreseeable future either because that simply isn't the scope of the project. It would take way to much time from the development to do it in the first place and it would also make all future develompent take much longer because every little change has to be documented. And there would still be no guarantee that your code would work in a future version, just that it would be documented that it wouldn't work anymore :)
Post Reply