Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BackupUser
PureBasic Guru
Posts: 16777133 Joined: Tue Apr 22, 2003 7:42 pm
Post
by BackupUser » Sat Jan 04, 2003 9:06 am
Restored from previous forum. Originally posted by JohnDeHope3 .
Can a structure be used as the data type for a procedure parameter? Is this something other people would like? Is there a reason why this is not good?
BackupUser
PureBasic Guru
Posts: 16777133 Joined: Tue Apr 22, 2003 7:42 pm
Post
by BackupUser » Sat Jan 04, 2003 9:52 am
Restored from previous forum. Originally posted by BigSnake .
Code: Select all
structure a
a.l
b.s
c.b
endstructure
procedure ChangeA(*A.a)
*A.a = 15
endprocedure
Global B.a
ChangeA(B)
BackupUser
PureBasic Guru
Posts: 16777133 Joined: Tue Apr 22, 2003 7:42 pm
Post
by BackupUser » Sat Jan 04, 2003 9:55 am
Restored from previous forum. Originally posted by JohnDeHope3 .
Ahh... So what you are saying is that the parameter should be a pointer, and that then I'll be OK? Do I have to prefix the parameter name (A in your example) with * everywhere in the procedure, or just in the top declaration line?
BackupUser
PureBasic Guru
Posts: 16777133 Joined: Tue Apr 22, 2003 7:42 pm
Post
by BackupUser » Sat Jan 04, 2003 9:55 am
Restored from previous forum. Originally posted by BigSnake .
ups sorry
BackupUser
PureBasic Guru
Posts: 16777133 Joined: Tue Apr 22, 2003 7:42 pm
Post
by BackupUser » Sat Jan 04, 2003 9:57 am
Restored from previous forum. Originally posted by BigSnake .
Yes, everywhere with the * prefix. If you don´t, you change the adress of the pointer; be carefull.
BackupUser
PureBasic Guru
Posts: 16777133 Joined: Tue Apr 22, 2003 7:42 pm
Post
by BackupUser » Sat Jan 04, 2003 9:58 am
Restored from previous forum. Originally posted by JohnDeHope3 .
I didn't catch that the first time! So do I have to say "*A\a" every time, or can I also say just "A\a" ?
BackupUser
PureBasic Guru
Posts: 16777133 Joined: Tue Apr 22, 2003 7:42 pm
Post
by BackupUser » Sat Jan 04, 2003 10:02 am
Restored from previous forum. Originally posted by JohnDeHope3 .
With a little test programming it seems you need to use the "*" everywhere. That's annoying! But hell at least now I can pass structures into my programs, which is nice.