Page 1 of 1
Adress Change
Posted: Wed Aug 02, 2006 8:34 pm
by AndyX
Will there be a feature in a future version of PB to allow changing the adress of a array,var,...?
Like that in C:
edit: Please don´t throw stones at me if that is a stupid idea!

Re: Adress Change
Posted: Wed Aug 02, 2006 9:38 pm
by Joakim Christiansen
AndyX wrote:PB 43.93 ROCKZ!!!
OMG, where did you get that version?

Posted: Wed Aug 02, 2006 9:41 pm
by AndyX
Stolen it from Freds safe

Re: Adress Change
Posted: Thu Aug 03, 2006 5:10 pm
by AndyX
AndyX wrote:Will there be a feature in a future version of PB to allow changing the adress of a array,var,...?
Like that in C:
edit: Please don´t throw stones at me if that is a stupid idea!

Is it a stupid idea?
Posted: Thu Aug 03, 2006 11:27 pm
by SCRJ
>>Is it a stupid idea?
Yes
I think that would be a nice feature...
Posted: Fri Aug 04, 2006 1:55 pm
by AndyX
It would really be a nice feature when handling large datas.
for example:
I have a 4x4 matrix that i want to clear out.
I would have to do 16 lines of
Code: Select all
matrix\m00 = 0
matrix\m01 = 0
....
Instead of this i could create a nullmatrix and easily set the adress of the matrix to the nullmatrix:
Posted: Fri Aug 04, 2006 2:27 pm
by Joakim Christiansen
Or you could simply do this:
Code: Select all
For x=0 To 3
For y=0 To 3
Array(x,y) = 0
Next
Next
Or just dim it again:
Code: Select all
Dim Array(3,3)
For x=0 To 3
For y=0 To 3
Array(x,y) = 1
Next
Next
Dim Array(3,3)
For x=0 To 3
For y=0 To 3
Debug Array(x,y)
Next
Next
;This is how to delete the content of an array and release its used memory
Dim Array(0)
Posted: Fri Aug 04, 2006 6:53 pm
by AndyX
But what if its not an array?
What about this:
Code: Select all
Structure OBJECT4DV1
id.l
name.s
state.l
attr.l
avg_radius.f
max_radius.f
world_pos.POINT4D
dir.VECTOR4D
ux.VECTOR4D
uy.VECTOR4D
uz.VECTOR4D
num_vertices.l
vlist_local.POINT4D[#OBJECT4DV1_MAX_VERTICES]
vlist_trans.POINT4D[#OBJECT4DV1_MAX_VERTICES]
num_polys.l
plist.POLY4DV1[#OBJECT4DV1_MAX_POLYS]
EndStructure
obj.OBJECT4DV1
Setting this to null eats lots of lines. edit/: and lots of time.
Well, if its so stupid, please some member of the Purebasic team come here and close this thread
edit: sorry if i´m annoying you ^^
Posted: Fri Aug 04, 2006 7:11 pm
by IceSoft
Is this your feature request?
Code: Select all
a.l = 5
*aPtr.l = @a
Debug PeekL(*aPtr)
b .l = 10
*aPtr = @b
Debug PeekL(*aPtr)
Posted: Fri Aug 04, 2006 7:24 pm
by AndyX
yes, it is.
But without having to use the PeekX()/PokeX() commands to get the value.
Posted: Fri Aug 04, 2006 7:29 pm
by Flype
or maybe, in particular case, you can use the 'swap a, b' keyword.
it works for vars, arrays and elements of linked-lists.
Code: Select all
Dim a.l(10)
Dim b.l(10)
For i = 0 To 9
b(i) = 100 + i
Next
Swap a(), b()
For i = 0 To 9
Debug a(i)
Next
Posted: Fri Aug 04, 2006 7:30 pm
by Flype
AndyX wrote:yes, it is.
But without having to use the PeekX()/PokeX() commands to get the value.
Code: Select all
a.l = 5
*aPtr.Long = @a
Debug *aPtr\l
b .l = 10
*aPtr.Long = @b
Debug *aPtr\l

Posted: Fri Aug 04, 2006 7:38 pm
by AndyX
Flype wrote:or maybe, in particular case, you can use the 'swap a, b' keyword.
it works for vars, arrays and elements of linked-lists.
Code: Select all
Dim a.l(10)
Dim b.l(10)
For i = 0 To 9
b(i) = 100 + i
Next
Swap a(), b()
For i = 0 To 9
Debug a(i)
Next
With Swap and large amount of datas you won´t know where what is after the time...
AndyX wrote:
yes, it is.
But without having to use the PeekX()/PokeX() commands to get the value.
Code:
a.l = 5
*aPtr.Long = @a
Debug *aPtr\l
b .l = 10
*aPtr.Long = @b
Debug *aPtr\l
Question
hm... but then i have to declare all things with * and .LONG, hmmmm..
Posted: Sat Aug 12, 2006 12:30 pm
by Trond
AndyX wrote:But what if its not an array?
What about this:
Code: Select all
Structure OBJECT4DV1
id.l
name.s
state.l
attr.l
avg_radius.f
max_radius.f
world_pos.POINT4D
dir.VECTOR4D
ux.VECTOR4D
uy.VECTOR4D
uz.VECTOR4D
num_vertices.l
vlist_local.POINT4D[#OBJECT4DV1_MAX_VERTICES]
vlist_trans.POINT4D[#OBJECT4DV1_MAX_VERTICES]
num_polys.l
plist.POLY4DV1[#OBJECT4DV1_MAX_POLYS]
EndStructure
obj.OBJECT4DV1
Setting this to null eats lots of lines. edit/: and lots of time.
Well, if its so stupid, please some member of the Purebasic team come here and close this thread
edit: sorry if i´m annoying you ^^
Remember it is initialized to 0 when you create it. And you can use this line to zero out the entire structure: