Developpez.com - Rubrique PureBasic

Le Club des Développeurs et IT Pro

PureBasic 4.40 bêta 1 est disponible

Le 2009-08-14 06:32:27, par comtois, Responsable Purebasic
La version 4.40 bêta 1 vient de sortir, elle est disponible sur votre compte.

Pour résumer les changements :

* Le compilateur a un nouveau mot clé "Threaded" pour créer des variables locales dans un thread, et deux nouveaux types de variables '.a' et '.u' pour les byte/word non signés.

* La bibliothèque 'Map' pour créer et utiliser facilement des tables de hachage.
* La bibliothèque '2DDrawing' entièrement réécrite , par exemple la fonction plot est nettement plus rapide, ajout de l'alpha-channel et support des gradients pour les images.

* Et finalement l'EDI a une meilleure gestion de l'auto complétion (notamment des structures) et comporte une gestion des projets.

* Et une nouvelle version pour linux x64 voit le jour.

Pour mieux comprendre les nouveautés et changement, vous trouverez une archive qui comporte quelques exemples :

http://www.purebasic.com/beta/v440_examples.zip

Voici la liste complète des changements et nouveautés :

- Added: Linux x64
- Added: Map Library for hash tables
- Added: 'Threaded' Keyword for thread-local variables
- Added: Structure assignment copies the structure (a.point = b.point)
- Added: ClearStructure(*Pointer, Structure)
- Added: AES to cipher library: AESEncoder(), AESDecoder(), StartAESCipher(), AddCipherBuffer(), FinishCipher()
- Added: Dylib for OS X
- Added: Trim/LTrim/RTrim() got an optional character to trim
- Added: Added #PB_Function, #PB_OSFunction, #PB_Map to Defined()
- Added: ReverseString(String$), InsertString(String$, StringToInsert$, Position), RemoveString(String$, RemoveString$ [, Mode [, StartPosition [, NbOccurences]]])
- Added: Add blob support to databases
- Added: Added peephole optimizer to 64 bit versions to produce better code
- Added: '.a' (ascii) and '.u' (unicode) native type to provide native unsigned byte and word.
- Added: FileBuffersSize(#PB_Default, ...): #PB_Default support change the buffersize to the next opened files
- Added: #PB_URL_Protocol to Get/SetURLPart()
- Added: #PB_Shadow_TextureAdditive
- Added: FTPDirectoryEntryRaw(), FillMemory(Memory, Value, Size [, Type])
- Added: Global, Protected, Threaded, Shared and Static now accept a type to affect all default variable declaration.

- Added: AddWindowTimer(), RemoveWindowTimer(), #PB_Event_Timer, EventTimer()
- Added: #PB_Window_Tool - create tool windows
- Added: StatusBarProgress()
- Added: StatusBarImage() - now supports normal images (not just icons)
- Added: #PB_Checkbox_ThreeState flag to create a 3 state checkbox (state values: #PB_CheckBox_Checked, #PB_CheckBox_Unchecked, #PB_CheckBox_Inbetween)
- Added: ShortcutGadget()

- Added: CreateImageMenu(), CreatePopupImageMenu() for OSX
- Added: Full alphachannel support for all GUI elements that display images
- Added: Full alphachannel support for Image lib

- Added: New drawing modes for 2DDrawing in ImageOutput()
- #PB_2DDrawing_AlphaBlend
- #PB_2DDrawing_AlphaClip
- #PB_2DDrawing_AlphaChannel
- #PB_2DDrawing_Gradient

- Added: LinearGradient(), BoxedGradient(), CircularGradient(), EllipsicalGradient(), ConicalGradient(),

CurtomGradient()
- Added: GradientColor(), ResetGradientColors()
- Added: DrawAlphaImage() for all outputs on all OS
- Added: DrawAlphaImage() has a new transparency parameter and can be used to draw non-alpha images part transparent

- Added: QuickDraw subsystem for WindowOutput() on OSX
- Added: Sprite/ScreenOutput for OpenGL (all OS)
- Added: DrawingFont() works for SDL output!
- Added: OutputWidth(), OutputHeight(), OutputDepth() for 2DDrawing
- Added: GrabDrawingImage(), DrawRotatedText()
- Added: RGBA(), Alpha()

- Added #PB_PixelFormat_ReversedY - for pixel buffers that are stored upside-down (Windows ImageOutput or OpenGl)
- Removed: #PB_Image_DisplayFormat is now deprecated (value set to 32 to have 32bit as default)

- Added: #PB_OS_Windows_7 for OSVersion()

- Updated: OGRE to 1.6.2, sqlite 3.6.14.2, PCRE to 7.9

- Changed: Call(C)Function(Fast) parameters have been changed from 'Any' to 'Integer'.
- Fixed: Image Decoders are now threadsafe

PureBasic IDE:
- Added: Highlight matching keyword for keyword under cursor (tied to BraceMatching color setting)
- Added: Edit->Goto matching keyword
- Added: PB_TOOL_Preferences Environment variable for IDE tools
- Added: Theme management to customize menu icons
- Added: New 'Silk' theme based on the Iconsset by Mark James

- Added: Autocomplete scans implicit variable declaration and respects scope
- Added: Structure item autocomplete

- Added: Project Management:
- Autocomplete for all files within a project (even if not opened)
- Multiple compiler settings for different compile targets
- Compile all compile targets at once
- Per-Project list of last opened files
- Project ToolsPanel tool for fast access to the project files

- Changed: moved encoding/newline setting from compiler options to file menu

Debugger:
- Improved: greatly improved VariableViewer update speeds
- Added: progressbar display if VariableViewer update takes long
- Added: column sort capability to VariableViewer (Windows Only)
  Discussion forum
5 commentaires
  • comtois
    Responsable Purebasic
    un petit exemple de 'NetMaestro', l'exemple d'un blob avec une base de données dans l'archive mentionnée précédemment et également de lui (retouché par Fred)

    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    Global x=300, y=500, dist=400
    Global text$ = "Purebasic"
    LoadFont(0,"Courier New", 60, #PB_Font_Bold|#PB_Font_HighQuality)
    
    Procedure PlotCharacter(char$, angle.d, charangle.d, color)
      p1 = x+dist*Cos(angle*#PI/180)
      p2 = y+dist*Sin(angle*#PI/180)
      DrawRotatedText(p1,p2,char$,charangle,color)
    EndProcedure
    
    CreateImage(0,600,600)
    StartDrawing(ImageOutput(0))
      Box(0,0,600,600,GetSysColor_(#COLOR_BTNFACE))
      DrawingFont(FontID(0))   
     
      angle.d = 235 : charangle.d = 31.3
      For i=1 To 9
        PlotCharacter(Mid(text$,i,1), angle, charangle, #Black)
        angle+8 : charangle-8
      Next
      dist+5
      angle.d = 234 : charangle.d = 32.3
     
      DrawingMode(#PB_2DDrawing_Gradient)
      GradientColor(0.0, #Red)
      GradientColor(0.1, #Blue)
      GradientColor(0.9, #Green)   
      GradientColor(1.0, #Red)
      ConicalGradient(x, y, 90)
     
      For i=1 To 9
        PlotCharacter(Mid(text$,i,1), angle, charangle, #Red)
        angle+8 : charangle-8
      Next
     
    
    StopDrawing()
    
    OpenWindow(0,0,0,600,600,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
    ImageGadget(0,0,0,0,0,ImageID(0))
    
    Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
    et l'exemple 'map.pb' dans l'archive peut être complété en utilisant ForEach/next pour lister le contenu d'une map.
    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    NewMap Test.l()
    
    Test("Fred") = 1
    Test("Timo") = 2
    
    ResetMap(Test())
    While NextMapElement(Test())
      Debug Test()
    Wend
    
    ForEach Test()
      Debug Test()
    Next
  • kOrt3x
    Modérateur
    Bonjour,

    As-tu un lien pour télécharger cette version ?
  • comtois
    Responsable Purebasic
    Je ne l'ai pas précisé, mais tu me donnes l'occasion de le faire.

    Il faut savoir que les versions bêta ne sont disponibles que pour les personnes ayant une licence (mise à jour gratuite à vie), elles ont un compte ouvert sur le site de PureBasic ('espace personnel' où tu peux télécharger toutes les versions de PureBasic, pour tous les OS).

    Voici le lien http://www.purebasic.com/french/download.php

    Si tu n'as pas de licence PureBasic, il faut attendre la sortie de la version finale.

    Une version démo est mise en ligne au plus tard quelques jours après la sortie de la version finale.
  • comtois
    Responsable Purebasic
    Et voici un exemple d'encodage AES par NetMaestro, au passage il en a profité pour utilisé la nouvelle option #PB_Window_Tool.

    Envoyé par Freak
    #PB_Window_Tool is a new flag for OpenWindow() to get a smaller titlebar and no taskbar entry.

    La création d'une clé MD5 c'est pas nécessaire, C'est un choix de l'auteur pour créer une clé complexe avec un texte long et simple à retenir.
    key$ = "Four score and seven years ago, and so on and so on"
    result$ = MD5Fingerprint(@key$, Len(key$))
    PokeS(*key, result$)

    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
     
    ; AES encryption: Streaming test 
    ; netmaestro Aug 2009 
    ; PB 4.40 Beta 1 
     
    Structure Init_Vector ; I picked an init vector size = cipher blocksize 
      byte.a[32]           ; 256 bits = 32 bytes 
    EndStructure 
     
    *initvector.Init_Vector = AllocateMemory(32) 
     
    RandomSeed(189470) ; for testing I'm using same init vector every time 
     
    For i=0 To 31 
      *initvector\byte[i] = Random(255) 
    Next 
     
    *key = AllocateMemory(32) ; Memory for the key 
     
    key$ = "Four score and seven years ago, and so on and so on" 
    result$ = MD5Fingerprint(@key$, Len(key$)) 
    PokeS(*key, result$) 
     
    test$="You can't handle the truth! Son, we live in a world that has walls. And those walls have to be guarded by men with guns." 
    test$+" Who's gonna do it? You? You, Lt. Weinberg? I have a greater responsibility than you can possibly fathom." 
    test$+" You weep for Santiago and you curse the Marines. You have that luxury. You have the luxury of Not knowing what I know:" 
    test$+" that Santiago's death, while tragic, probably saved lives. and my existence, while grotesque and incomprehensible" 
    test$+" to you, saves lives...You don't want the truth. Because deep down, in places you don't talk about at parties," 
    test$+" you want me on that wall. You need me on that wall. We use words like honor, code, loyalty...we use these words" 
    test$+" As the backbone to a life spent defending something. You use 'em as a punchline. I have neither the time nor the inclination" 
    test$+" to explain myself to a man who rises and sleeps under the blanket of the very freedom I provide, then questions the manner" 
    test$+" in which I provide it! I'd rather you just said thank you and went on your way. Otherwise, I suggest you pick up a weapon" 
    test$+" and stand a post. Either way, I don't give a damn what you think you're entitled to! " 
     
     
    *raw     = AllocateMemory(StringByteLength(test$)+SizeOf(character)) ; Memory for the original string 
    *secure  = AllocateMemory(StringByteLength(test$)+SizeOf(character)) ; Memory for the encoded string 
    *decoded = AllocateMemory(StringByteLength(test$)+SizeOf(character)) ; Memory for the string after decoding 
     
    PokeS(*raw, test$) ; String goes into the *raw memory block 
     
     
    ; Ready to go; try StartAesCipher - AddCipherBuffer - FinishCipher 
     
    ;============================================================================= 
    ; Encode 
     
      chunksize = 128 ; Chunksize must be a multiple of 16 
     
      numparts = MemorySize(*raw)/chunksize 
      lastbit  = MemorySize(*raw)%chunksize 
     
      StartAESCipher(0, *key, 256, *initvector, #PB_Cipher_CBC|#PB_Cipher_Encode) 
      
      *srcloc  = *raw     ; Start pointers at the beginning of memory blocks 
      *destloc = *secure 
      
      For i=1 To numparts 
        AddCipherBuffer(0, *srcloc, *destloc, chunksize) 
        *srcloc  + chunksize ; increment pointers for src and dest 
        *destloc + chunksize ; by the number of bytes in chunksize 
      Next 
     
      If lastbit 
        AddCipherBuffer(0, *srcloc, *destloc, chunksize) 
      EndIf 
      
      FinishCipher(0) 
     
      
    ;============================================================================= 
    ; Decode 
     
      chunksize = 16 ; I picked a different chunksize for decoding, just for fun 
     
      numparts = MemorySize(*secure)/chunksize 
      lastbit  = MemorySize(*secure)%chunksize 
     
      StartAESCipher(0, *key, 256, *initvector, #PB_Cipher_CBC|#PB_Cipher_Decode) 
      
      *srcloc  = *secure     ; Start pointers at the beginning of memory blocks 
      *destloc = *decoded 
      
      For i=1 To numparts 
        AddCipherBuffer(0, *srcloc, *destloc, chunksize) 
        *srcloc  + chunksize ; increment pointers for src and dest 
        *destloc + chunksize 
      Next 
     
      If lastbit 
        AddCipherBuffer(0, *srcloc, *destloc, chunksize) 
      EndIf 
      
      FinishCipher(0) 
     
     
    ;============================================================================ 
    ; Did it decode all right? 
     
      OpenWindow(0,0,0,320,320,"Decoded text:",#PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_Tool) 
      SetWindowColor(0,#White) 
      EditorGadget(0,20,20,280,280,#PB_Editor_ReadOnly) 
      SetWindowLongPtr_(GadgetID(0),#GWL_EXSTYLE,GetWindowLongPtr_(GadgetID(0),#GWL_EXSTYLE) &~ #WS_EX_CLIENTEDGE) 
      SetWindowPos_(GadgetID(0), 0,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE|#SWP_NOZORDER|#SWP_FRAMECHANGED) 
      SendMessage_(GadgetID(0), #EM_SETTARGETDEVICE, 0,0) 
      SetGadgetText(0, PeekS(*decoded)) 
      Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
  • comtois
    Responsable Purebasic
    Le premier post est mis à jour pour signaler :

    - Mise à jour de PCRE (version 7.9)
    - Définition de RemoveString()
    - Nouvelle commande FillMemory(). Les types possibles sont #PB_Byte, #PB_Word and #PB_Long.
    - ShortcutGadget() - Freak utilise ce gadget dans l'EDI pour configurer les raccourcis clavier.

    code pour tester, tapez une touche ou une combinaison avec CTRL, SHIFT, ALT pour afficher la saisie :

    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    If OpenWindow(0, 200, 200, 260, 30, "Raccourci clavier", #PB_Window_SystemMenu | #PB_Window_Tool)
    
      ShortcutGadget(0, 5, 5, 250, 20, #PB_Shortcut_A)
      Repeat
        Event = WaitWindowEvent()
    
        If Event = #PB_Event_CloseWindow
          Quit = 1
        EndIf
    
      Until Quit = 1
     
    EndIf