Voici la section complète avec les pointeurs (avec les dernières modifs d'André)
Y'en a déjà un bout de traduit dans la doc française.
@Section Pointers
To use a pointer, put * before the @ReferenceLink "variables" "variable" name. A pointer is normally a long variable which stores an address.
It is generally associated with a @ReferenceLink "structures" "structured type". So, you can access the structure via the pointer.
@Example
@Code
*MyScreen.Screen = OpenScreen(0,320,200,8,0)
mouseX = *MyScreen\MouseX ; Assuming than the Screen structure contains a MouseX field
@EndCode
There are only three valid methods to set the value of a pointer: @LineBreak
- Get the result from a function (as shown in the above example) @LineBreak
- Copy the value from another pointer @LineBreak
- Find the address of a variable, procedure or label (as shown below) @LineBreak
@LineBreak
Note: Other than in C/C++ in PureBasic the * is @Bold always part of the variable name.
Therefore *ptr and ptr are two different variables.
@LineBreak
@LineBreak
@Underline "Some technical background about pointers in PureBasic:"
@LineBreak
@LineBreak
When you declare a @ReferenceLink "variables" "variable" with an '*', it's a pointer,
which means it will be always the size of the CPU address mode (4 bytes on 32 bits CPU
and 8 bytes on 64 bits one for example). When you attach a structure to a pointer
(for example *MyPoint.Point) it allows to access any memory address in a structured way.
@LineBreak
@LineBreak
Example:
@Code
Point1.Point
Point2.Point
*CurrentPoint.Point = @Point1
*CurrentPoint\x = 10 ; 10 is affected to Point1
*CurrentPoint.Point = @Point2
*CurrentPoint\x = 10 ; 10 is affected to Point2
@EndCode
So a pointer isn't always a 'long' because it needs to have the room to store an
absolute address. On 32 bits processors the address space is limited to 32 bits, so a
pointer takes 32 bits (4 bytes, like a 'long') in memory. On newer 64 bits processors
it takes 64 bits (8 bytes, like a 'quad') in memory, because the absolute address is
on a 64 bits range.
@LineBreak
@LineBreak
The type you affect to a pointer is a different thing. For example: *Pointer.l,
*Pointer.b or *Pointer.q will make no difference at all as the types l, b and q doesn't
have any fields in them. Pointer makes sense mainly with a @ReferenceLink "structures" "structure".
@LineBreak
@LineBreak
A pointer has always the same size (which is processor dependent), whatever type
(structure or not) is put after. A pointer is just an easy way to access a structured
memory area. Also *Pointer.l and *Pointer.Long are the same, except than with the
second one you can really read the long at the specified address, due to the 'l'
structure field.
@LineBreak
@LineBreak
Please note, that PureBasic can't create 64 bit executables (yet).
@LineBreak
As long as PureBasic executables are compiled as 32 bit applications the system will only
provide the program with a 32 bit address space.
Dräc , dis moi si tu utilises cvs , dans ce cas c'est peut-être pas la peine que je copie ici ce que tu peux récupérer comme un grand chez toi
