Got an idea for enhancing PureBasic? New command(s) you'd like to see?
AndyX
User
Posts: 12 Joined: Wed May 04, 2005 6:40 pm
Location: Austria
Post
by AndyX » Wed Aug 02, 2006 8:34 pm
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!
Joakim Christiansen
Addict
Posts: 2452 Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:
Post
by Joakim Christiansen » Wed Aug 02, 2006 9:38 pm
AndyX wrote: PB 43.93 ROCKZ!!!
OMG, where did you get that version?
I like logic, hence I dislike humans but love computers.
AndyX
User
Posts: 12 Joined: Wed May 04, 2005 6:40 pm
Location: Austria
Post
by AndyX » Wed Aug 02, 2006 9:41 pm
Stolen it from Freds safe
AndyX
User
Posts: 12 Joined: Wed May 04, 2005 6:40 pm
Location: Austria
Post
by AndyX » Thu Aug 03, 2006 5:10 pm
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?
SCRJ
User
Posts: 93 Joined: Sun Jan 15, 2006 1:36 pm
Post
by SCRJ » Thu Aug 03, 2006 11:27 pm
>>Is it a stupid idea?
Yes
I think that would be a nice feature...
AndyX
User
Posts: 12 Joined: Wed May 04, 2005 6:40 pm
Location: Austria
Post
by AndyX » Fri Aug 04, 2006 1:55 pm
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:
Joakim Christiansen
Addict
Posts: 2452 Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:
Post
by Joakim Christiansen » Fri Aug 04, 2006 2:27 pm
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)
I like logic, hence I dislike humans but love computers.
AndyX
User
Posts: 12 Joined: Wed May 04, 2005 6:40 pm
Location: Austria
Post
by AndyX » Fri Aug 04, 2006 6:53 pm
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 ^^
IceSoft
Addict
Posts: 1682 Joined: Thu Jun 24, 2004 8:51 am
Location: Germany
Post
by IceSoft » Fri Aug 04, 2006 7:11 pm
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)
Belive! C++ version of Puzzle of Mystralia
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
AndyX
User
Posts: 12 Joined: Wed May 04, 2005 6:40 pm
Location: Austria
Post
by AndyX » Fri Aug 04, 2006 7:24 pm
yes, it is.
But without having to use the PeekX()/PokeX() commands to get the value.
Flype
Addict
Posts: 1542 Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy
Post
by Flype » Fri Aug 04, 2006 7:29 pm
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
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Flype
Addict
Posts: 1542 Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy
Post
by Flype » Fri Aug 04, 2006 7:30 pm
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
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
AndyX
User
Posts: 12 Joined: Wed May 04, 2005 6:40 pm
Location: Austria
Post
by AndyX » Fri Aug 04, 2006 7:38 pm
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..
Trond
Always Here
Posts: 7446 Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway
Post
by Trond » Sat Aug 12, 2006 12:30 pm
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: