PureBasic Survival Guide

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

Spot on.

A fixed length string is a preallocated block of memory, where you store strings or other data. As such, that part of memory can contain a null. However, all other (string) commands consider the null to be the end of the string.

Also, I do not know if fixed length strings are moved around in memory when PureBasic does some garbage recollection. Perhaps one of the PBdevs could tell us?

Fixed length strings are best used in, for example, structures. Regular strings that are part of a structure are NOT stored 'inside' the memory block where the structure resides, instead that memory block would contain a pointer to the real string. If you want to dump a number of those structs directly from memory to disk, you'd lose the actual string data.

Some DLL's use structures with fixed fields to communicate, for example the CAPI library. There are also some industrial protocols where a certain amount of text occupies a fixed part of the message.

In those cases fixed length strings are of great help.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

PB wrote: The guide needs to explain it more clearly, then. :) It confused me.
That guide has been around for a couple of years now, guess this is the first time you're reading it? :-)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Yes, it is. Well, reading it properly rather than just skimming through. :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

Update.

Many small changes and corrections in parts I II III IV and V, whilst I'm looking forward to 4.40 final :-)

(I know IV and further on need to be checked against the later versions as there is still some 3.9x in there, but I'm going to wait for 4.40 final to avoid duplicate work.)

Note that pages marked as 'under construction' still *may* :-) contain usable information :-)

As usual:

http://www.xs4all.nl/~bluez/datatalk/purebasic.htm
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

Update.

Started to add some stuff on unsigned variable types for 4.40b1. If you're confused by signed versus unsigned go and have a look. Comments appreciated.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Post by djes »

Thanks for the updates!

I noticed a little error in http://www.xs4all.nl/~bluez/datatalk/pu ... _variables :
For example, the PureBasic type 'byte' can hold values ranging from -127 to +127, whilst in most other
Byte can hold values ranging from -128 to +127... This error is repeated several times, and for other types (-32768 +32767 ...).

Keep on the good work!
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

Okay, will change it. Thanks. I'll add it to the next update.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

Update.

Added Threaded and maps / hash tables / subsystems and some other small changes.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
GeBonet
Enthusiast
Enthusiast
Posts: 135
Joined: Fri Apr 04, 2008 6:20 pm
Location: Belgium

Post by GeBonet »

I'm really glad that this guide exists. The perfect complement to the official manual. I regret that there have not the same in French.
I know that Comtois is very involved with the official manual in French and does a very good work too.

But this is not the same thing, we talk about something and more complete example. Unfortunately I do not know enough English to translate. And with the translator is too complicated. Which is just good to understand what this mean's it. :?
Very good work and always (almost) update.
Thank you very much :lol:
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: PureBasic Survival Guide - update

Post by blueznl »

Update.

Some updates left and right, plus blob's, databases, MySQL, and a bit more on VirtualBox.

As usual:

http://www.xs4all.nl/~bluez/datatalk/purebasic.htm
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: PureBasic Survival Guide - update

Post by blueznl »

Update.

Sections on MySQL and VirtualBox are now complete.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: PureBasic Survival Guide - update

Post by blueznl »

Update.

Some examples, updated downloadable version, some errors corrected, started working on the networking section.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
GeBonet
Enthusiast
Enthusiast
Posts: 135
Joined: Fri Apr 04, 2008 6:20 pm
Location: Belgium

Re: PureBasic Survival Guide - update

Post by GeBonet »

Hello,

For the "map" that resume of sample may be can help the sample for the survival ? or some one ?

Code: Select all

; ==================================================================
;   Autre Exemple / Other sample  : 
; ==================================================================
    NewMap Test.s() ; Table indexé selon le Hascode Sur la Clef .....
    Dim T$(5)              ; Table qui contientdrait les clefs.... indépendament de  Test.s()
    ;                            
    ;                               Ordre de création ....
    T$(1)="Fred"      :Test(T$(1)) = "1 -Toute une phrase qui contient tout les élément désiré "
    T$(2)="Timo"     :Test(T$(2)) = "2- deux ou 2"
    T$(3)="Albert"    :Test(T$(3)) = "3- Et ceci c'est le complément"
    T$(4)="Joseph" :Test(T$(4)) = "4- c'est une série B"
    T$(5)="Dorothe":Test(T$(5)) = "5- It's not a joke but not serious"
    ;--------------------------------------------------------
    Debug " == Organisation de la table selon le Hash coding de Map ==="
    ResetMap(Test())                        ;  Move to the begin of the Map - Deplace le pointeur en tête de la "map"
    While NextMapElement(Test())
        Debug Str(l+1)+" - "+Test()    ; Here is the order of the map....  Ici l'ordre dans la table 
        l+1
    Wend
    l=0
    Debug "====================================================="   
    Debug " Ordre selon l'appel par les clefs... donc de l'enregistrement correspondant"    
    Debug "-----------------------------------------------------------------------------------------------"
    ;--------------------------------------------------------------------------------------------------------------------    
    ;  Ordre d'extraction par appel en utilisant la clef    / Calling Forme 
    ;-------------------------------------------------------------------------------------------------------------------- 
    ;  1 on appelle la première clef du de T$(1)
    FindMapElement(Test.s(), "Fred")
        Debug "Fred="+Test.s()
    
    ;  2  on appelle la quatrième clef de T$(4)
    FindMapElement(Test.s(), "Joseph")
        Debug "Joseph"+"="+Test.s()
    
    ;   3 on appelle la cinquième clef de T$(5)
    FindMapElement(Test.s(), "Dorothe")
        Debug "Dorothe"+"="+Test.s()
    
    ;  4  on appelle la cinquième clef de T$(2)
    B$="Timo"
    FindMapElement(Test.s(), B$)
        Debug B$+"="+Test.s()
    
    ; 5  on appelle la cinquième clef de T$(3) ="Albert"
    ;           
    FindMapElement(Test.s(), T$(3))
        Debug B$+"="+Test.s()
        
    ; ----------------------------------------------------------------------------------------------    
    Debug "===== Numero element ======="
    Debug "Donné par MapSize()="+Str(MapSize(Test()))
    Debug "========================="        
    ; ---------------------------------------------------------------------------------------------- 
    ResetMap(Test())                        ;  Move to the begin of the Map - Deplace le pointeur en tête de la "map"
    
    While NextMapElement(Test())
        Debug Str(l+1)+" - "+Test()    ; Here is the order of the map....  Ici l'ordre dans la table 
        l+1
    Wend
    
    Debug "======================="   
    Debug " classement par ordre des clefs"
    Debug "-------------------------------------------------"
    ;                                            OR 
    ResetMap(Test())                        ;  Move to the begin of the Map - Deplace le pointeur en tête de la "map"
    For i=1 To 5
        Debug Str(i)+" - "+Test(T$(i)) ; Here is we find with the key.... geved from the array T$(i)...  recupère par la clef... 
    Next i        
    Debug "--------------- Autre forme d'utilisation de Map -----------------"
    ;
    FindMapElement(Test.s(),InputRequester("Recherche","Donnez la clef d'accès : ", Clef$))
    MessageRequester("Votre réponse est : ",Test.s(),#PB_MessageRequester_Ok  )
    ;
    Debug Test.s()
    Debug "---------------- FIN -------------------------"
    ;
    ClearMap(Test.s()) 
And me be you now wat is the using of "Flag" in the "; AddMapElement(Map(), Key$ [, Flags])"
and wat we can do with im... ?
:wink:
Sorry for my english :wink: ! (Windows Xp, Vista and Windows 7, Windows 10)
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: PureBasic Survival Guide - update

Post by blueznl »

Update.

Added PostgreSQL.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: PureBasic Survival Guide - update

Post by blueznl »

Update.

Some minor fixes, and I created a batch file to make my life easier when it comes to keeping the downloadable version up to date.

The guide is here:

http://www.xs4all.nl/~bluez/datatalk/purebasic.htm

The downloadable version you will find here:

http://www.xs4all.nl/~bluez/datatalk/survival_guide.arj
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Post Reply