Quick pointer question

Everything else that doesn't fall into one of the other PB categories.
Amiga5k
Enthusiast
Enthusiast
Posts: 329
Joined: Fri Apr 25, 2003 8:57 pm

Quick pointer question

Post by Amiga5k »

In the manual, under Pointers and Memory Access is this example:

Code: Select all

*MyScreen.Screen = OpenScreen(0,320,200,8,0)
  mouseX = *MyScreen\MouseX ; Assuming than the Screen structure contains a MouseX field
Judging by the above, it looks like the OpenScreen() function returns a pointer of some kind.

Can someone explain this example a bit? I understand pointers 90%, but the fact that this example uses the OpenScreen() function is what throws me off a little.

Thanks in advance!
Russell

p.s. If other commands return a pointer to a structure, then it may mean we can get the address of sprites, images, etc.... (If we can get the format of the returned structure - what fields are available, etc).
*** Diapers and politicians need to be changed...for the same reason! ***
*** Make every vote equal: Abolish the Electoral College ***
*** www.au.org ***
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post by Xombie »

Yeah. It seems like it's returning an address to a structure full of information about the newly created OpenScreen() call. So you copy the address locally into *MyScreen and then reference *MyScreen\XXXXXX to get whatever bit of information you need from the structure.

I can't seem to find any information on what the Screen structure is or information under OpenScreen about it's return value, however. Also, I've never used OpenScreen() or any other sprite function so... ^_^
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Re: Quick pointer question

Post by traumatic »

Amiga5k wrote:[...](If we can get the format of the returned structure - what fields are available, etc).
It's far form perfect but some internals are explained in
"/PureBasic/Library SDK/PureBasic library descriptor.txt"
Good programmers don't comment their code. It was hard to write, should be hard to read.
Amiga5k
Enthusiast
Enthusiast
Posts: 329
Joined: Fri Apr 25, 2003 8:57 pm

Post by Amiga5k »

Thanks traumatic, I'll check it out!

Russell

p.s. Saw Sin City last night. Strange. Gory. Fascinating overall. I give it 4 out of 5 stars (the second story is the best).
*** Diapers and politicians need to be changed...for the same reason! ***
*** Make every vote equal: Abolish the Electoral College ***
*** www.au.org ***
Post Reply