Page 1 of 1

(again) ways to dim from an array pointer?

Posted: Sat Jun 18, 2005 1:38 am
by dagcrack
I have a pointer of an array which is already full of yummy data, however, I have a procedure which requires an array pointer to be passed, thats no problem, but as I want to change some entries of the array inside this procedure, I should re-dim it.. but however, if I do that, the new array will be empty. is it possible to "fill" an empty array (of the same size of coursex) if I have the pointer of an already filled of data array ?

I just find PB very limitating when it comes to arrays and as I never seen this done, I came, I asked, I drank a beer.


:? Any ex guru (now enthusiast?) got a clue of how to achive this? is it even possible in pb 3.93?.

Please.. dont say "4.0 will support this, just wait" because thats a little sad ;) .. A little mind-repressing as well!.



Cheers!
Will give out free beer if someone suggests a solution


:lol:

Posted: Sat Jun 18, 2005 1:47 am
by dagcrack
Well.. I dont really need this anymore! But it would be nice to know if its possible, as I might need it soon (I needed this some time ago, you can see a thread I made here asking but go no solution that time).

However now its different..

Posted: Sat Jun 18, 2005 2:31 am
by Max.
dagcrack wrote:Well.. I dont really need this anymore! But it would be nice to know if its possible, as I might need it soon (I needed this some time ago, you can see a thread I made here asking but go no solution that time).

However now its different..
Not sure if I understood the question. Do you mean something like this?

Code: Select all

; different sized arrays
Dim a.b(49)
Dim b.b(99)

;filling them with different data
For i= 0 To 49
  a(i)=i
Next i

For i=0 To 99
  b(i)=99-i
Next i

;test before copy
For i=0 To 49
  Debug Str(a(i))+" / "+Str(b(i))
Next i

;copy array a to array b
Result = CopyMemory(@a(0),@b(0),50)

;test after copy
Debug "---"
For i=0 To 49
  Debug Str(a(i))+" / "+Str(b(i))
Next i

For i=50 To 99
  Debug " / "+Str(b(i))
Next i

Posted: Sat Jun 18, 2005 3:37 am
by dagcrack
Not really.
Its not about different sized arrays, but I might write some pseudo code soon if no one understands the question :?

Posted: Sat Jun 18, 2005 11:31 am
by Max.
dagcrack wrote:Not really.
Its not about different sized arrays, but I might write some pseudo code soon if no one understands the question :?
The different sizes were just used because you said "I should re-dim it".

The point is, you can use can get pointers to arrays and you can copy array data using CopyMemory.

Some pseude code could really help.