PokeB (@wsaversion + 1, low) ; ... and minor version number into high byte
If WSAStartup_ (wsaversion, wsa.WSAData) = #NOERROR ; Try to access Windows sockets stuff...
*host.HOSTENTSTRU = gethostbyname_ (computer$) ; Get host information for named computer...
If *host <> #Null
ip = PeekL(PeekL (*host\h_list))
ips$ = PeekS (inet_ntoa_ (PeekL(PeekL (*host\h_list)))) ;
may I recomend reading "Pointers and memory access" in the manual
Pointers and memory access
Pointers
To use a pointer, put * before the variable name. A pointer is a long variable which stores an address. It is generally associated with a structured type. So, you can access the structure via the pointer.
Example:
*MyScreen.Screen = OpenScreen(0,320,200,8,0)
mouseX = *MyScreen\MouseX ; Assuming than the Screen structure contains a MouseX field
There are only three valid methods to set the value of a pointer:
- Get the result from a function (as shown in the above example)
- Copy the value from another pointer
- Find the address of a variable, procedure or label (as shown below)
Note: Other than in C/C++ in PureBasic the * is always part of the variable name. Therefore *ptr and ptr are two different variables.
Addresses of variables
To find the address of a variable in your code, you use the at symbol (@). A common reason for using this is when you want to pass a structured type variable to a procedure. You must pass a pointer to this variable as you cannot pass structured variables directly.
Example:
For advanced programmers. The most common reason to get the address of a procedure is when dealing with the OS at a low-level. Some OSes allow you to specify callback or hook functions (for some operations) which get called by the OS and allows the programmer to extend the ability of the OS routine. The address of a procedure is found in a similar way to variables.
Example:
Procedure WindowCB(WindowID.l, Message.l, wParam.l, lParam.l)
; This is where the processing of your callback procedure would be performed
EndProcedure
; A special callback for the Windows OS allowing you to process window events
SetWindowCallback( @WindowCB() )
Addresses of labels
It can also be useful to find the address of labels in your code. This can be because you want to access the code or data stored at that label, or any other good reason you can think of. To find the address of a label, you put a question mark (?) in front of the label name.
Example:
Debug "Size of data file = " + Str(?endofmydata - ?mydata)