Page 1 of 1

Looking for 2 tutorials

Posted: Thu Nov 25, 2010 11:35 pm
by Tenaja
I'm looking for two several tutorials. I've searched and haven't found any that are particularly helpful.

The first is to cover the utilization of two threads. For instance, I've got two tasks that are typically done sequentially. However, with two threads, the second task could begin as soon the first one got going. It would just need a way to check on the status of the first thread, since that would be the slowest one.

The second is to cover the basics of using the debugger. I know how to print a debug message, but I'd like to learn how to step through the code one line at a time.

...I guess a pointer tutorial would be handy too. I find the syntax a bit unorthodox. (Backslash? and you can't find it in the help file...)

Oh, yeah. Since I'm asking away; is there an example for implementing online updates for your program?

Thanks!

Re: Looking for 2 tutorials

Posted: Fri Nov 26, 2010 12:08 am
by blueznl
Threads:

http://www.xs4all.nl/~bluez/purebasic/p ... #7_threads

Debugger: either set a breakpoint or add calldebugger, from that point on you can step through your code.

Re: Looking for 2 tutorials

Posted: Fri Nov 26, 2010 11:32 am
by Trond
...I guess a pointer tutorial would be handy too. I find the syntax a bit unorthodox. (Backslash? and you can't find it in the help file...)
Pointers in PB are very simple to understand, once you understand structures (which are also simple to understand).

To understand structures open the help file on the page "structures". The \ is explained there. A structure in PB is similar to a struct in C or record in pascal, except the \ character is used to access the fields/members.

Pointers are very simple to explain if you know pointers from C. If a variable name starts with a *, then that variable is a pointer (this is explained in the manual on the page "Pointers and memory access"). The * is part of the variable name, and can not be omitted ever.
If you come from a C background:
1. The variable name without specified member fields (*pointer, *mypointer, *happypointer, *etc) is never dereferenced.
2. The variable name with a specified member field (*pointer\member, *mypointer\arrowhead, *happypointer\xpos, *etc\ad_infinitum) is always dereferenced.
3. To get the address of a variable (any variable except .s), place the @ operator in front of the variable name (@*pointer (address of *pointer), @player1 (address of player1), @etc\address_of_member_field, @*pointer\address of member field pointed to by *pointer).

Re: Looking for 2 tutorials

Posted: Fri Nov 26, 2010 3:46 pm
by PureLust
The Tutorial-Section of PureArea.net provides some interesting links.

The Pointer-Tutorial from Timo Harter and Stefan Mahr may be helpful (at least you can read german language). :wink:

Also the Structures and pointers section in Blueznls PureBasic-Survival-Guide may be helpful to you.
Tenaja wrote: I find the syntax a bit unorthodox. (Backslash? and you can't find it in the help file...)
Jupp, some things are quite difficult to find in the help.
But Backslash has nothing to do with Pointers. It relays to Structures, so you should have a look in the Structures-Section of the Help.