PureBasic v4 - Changes

 On this site you get an overview about all the changes, brought by

 the new PureBasic version v4 compared to their predecessor version v3.94.

 

Changes by libraries from PureBasic v3.94 to v4.00:

Image

removed : UseImage() - change UseImage(#Image) to ImageID(#Image) where just the ID is needed.

added: CreateImage(#Image, Width, Height [, Depth]) - New Parameter
added: LoadImage(#Image, FileName$ [, Flags]) - New Parameter
added: CatchImage(#Image, FileName$ [, Length [, Flags]]) - New Parameters

changed: ImageDepth(#Image) - new parameter
changed: ImageHeight(#Image) - new parameter
changed: ImageWidth(#Image) - new parameter
changed: ImageID(#Image) - new parameter
changed: ImageOutput(#Image) - new parameter

String

added: StrD(Number [, NbDecimals])
added: StrQ()
added: HexQ()
added: BinQ()
added: StrU(): added a #PB_Quad flag
added: ValD(), ValQ()
added: StringByteLength() - to calculate the needed length of a string in the different encoding supported by PureBasic

Math

added: IntQ()

Thread

added: IsThread(Thread) - test if thread (still) exists.
added: CreateMutex() - create a mutex object
added: FreeMutex(Mutex) - destroy the object
added: LockMutex(Mutex) - wait until mutex is available and lock it
added: TryLockMutex(Mutex) - lock mutex if available, otherwise return 0 immediately
added: UnlockMutex(Mutex) - unlock the mutex so other threads can lock it

Process (New)

added: GetEnvironmentVariable(Name$) - get value of an en var
added: SetEnvironmentVariable(Name$, Value$) - set the value
added: RemoveEnvironmentVariable(Name$) - delete environment variable
added: ExamineEnvironmentVariables() - examine the currently set env variables
added: NextEnvironmentVariable() - get the next variable
added: EnvironmentVariableName() - get the variable name
added: EnvironmentVariableValue() - get the variable value
added: ProgramName() - get full path to executable
added: CountProgramParameters() - get parameters count
added: IsProgram(Program) - check if Program is a valid program created with RunProgram
added: ProgramID(Program) - get the ProcessID of the program
added: ProgramRunning(Program) - returns 1 if the program is still running
added: WaitProgram(Program [, Timeout]) - waits for the program to quit (with optional timeout) returns 1 if the program has ended
added: KillProgram(Program) - forcibly terminates the program
added: ProgramExitCode(Program) - get the exitcode of the program (only valid after program has ended)
added: CloseProgram(Program) - close the interaction with the program
added: AvailableProgramOutput(Program) - returns the number of bytes available for reading
added: ReadProgramString(Program) - read a string from the program output
added: ReadProgramData(Program, *Buffer, size) - read data from the output
added: ReadProgramError(Program) - read a message from STDERR
added: WriteProgramString(Program, String$) - write to the programs input (string)
added: WriteProgramData(Program, *Buffer, size)- write data to the programs input

changed: ProgramParameter([Index]) - get next (or at position index) parameter
changed: RunProgram() with new Flags:
  #PB_Program_Open    - open the program communicate/get information
  #PB_Program_Read    - allow to read the programs output (STDOUT)
  #PB_Program_Write   - allow to write to the programs input (STDIN)
  #PB_Program_Error   - allow to catch messages on standard error (STDERR)
  #PB_Program_Connect - connect another program's output to this program's input

File

added: FileBuffersSize(#File, Size) - Change the size of the buffers for the specified file.
added: FileID(#File) - Returns the unique ID which identifies the file in the operating system.
added: FlushFileBuffers(#File) - Ensure than all buffered operations are written to disk.
added: ReadChar(#File)
added: ReadQuad(#File)
added: ReadDouble(#File)
added: WriteChar(#File, Value)
added: WriteQuad(#File, Value)
added: WriteDouble(#File, Value)
added: ReadStringFormat(#File)
added: WriteStringFormat(#File, Format)

changed: FileSeek(#File, NewPosition) - new parameter
changed: WriteData(#File) - new parameter
changed: ReadData(#File) - new parameter
changed: Lof(#File) - new parameter
changed: Loc(#File) - new parameter
changed: ReadByte(#File) - new parameter
changed: ReadWord(#File) - new parameter
changed: ReadLong(#File) - new parameter
changed: ReadFloat(#File) - new parameter
changed: ReadString(#File [,Format]) - new parameter
changed: ReadData(#File) - new parameter
changed: WriteByte(#File, Data) - new parameter
changed: WriteWord(#File, Data) - new parameter
changed: WriteLong(#File, Data) - new parameter
changed: WriteFloat(#File, Data) - new parameter
changed: WriteString(#File, Data [,Format]) - new parameter
changed: WriteStringN(#File, Data [,Format]) - new parameter
changed: WriteData(#File, Data, Length) - new parameter

removed : UseFile() - change UseFile(#File) to FileID(#File) where just the ID is needed.

2DDrawing

added: DrawAlphaImage()
added: TextHeight(Text$) - returns the height required for the string with the current drawing font/output
added: FillArea(x, y, BorderColor [, Color]) - if BorderColor = -1, it fills the area with the same color as on (x,y)

changed: FrontColor(Color) - joined the red, green, blue to only one color value. (add RGB() for a quick adjustion of old code)
changed: BackColor(Color) - joined the red, green, blue to only one color value.
changed: NewX = DrawText(x, y, Text$ [, FrontColor [, BackColor]]) - added x/y coordinates and optional color values
changed: TextLength(Text$) -> TextWidth(Text$) - renamed

removed: Locate(x, y) - no longer useful.

Palette

removed: UsePalette()

changed: GetPaletteColor(#Palette, Index) - new Parameter
changed: SetPaletteColor(#Palette, Index, Color) - new Parameter

Module

changed: SetModulePosition(#Module, Position) - new Parameter
changed: GetModulePosition(#Module) - new Parameter
changed: GetModuleRow(#Module) - new Parameter
changed: StopModule(#Module) - new Parameter and -1 = stop all the modules

Database

changed: FirstDatabaseRow(#Database) - new Parameter
changed: PreviousDatabaseRow(#Database) - new Parameter
changed: NextDatabaseRow(#Database) - new Parameter
changed: GetDatabaseLong(#Database) - new Parameter
changed: GetDatabaseFloat(#Database) - new Parameter
changed: GetDatabaseString(#Database) - new Parameter
changed: DatabaseUpdate(#Database, Query$) - new Parameter
changed: DatabaseQuery(#Database, Query$) - new Parameter
changed: DatabaseColumnType(#Database, Column) - new Parameter
changed: DatabaseColumns(#Database) - new Parameter
changed: DatabaseColumnName(#Database, Column) - new Parameter

removed: UseDatabase()

Movie

changed: MovieAudio(#Movie) - new Parameter
changed: MovieHeight(#Movie) - new Parameter
changed: MovieWidth(#Movie) - new Parameter
changed: MovieInfo(#Movie) - new Parameter
changed: MovieLength(#Movie) - new Parameter
changed: RenderMovieFrame(#Movie) - new Parameter
changed: ResizeMovie(#Movie, x, y, Width, Height) - new Parameter
changed: ResumeMovie(#Movie) - new Parameter
changed: PauseMovie(#Movie) - new Parameter
changed: StopMovie(#Movie) - new Parameter
changed: MovieSeek(#Movie, Position) - new Parameter
changed: MovieStatus(#Movie) - new Parameter

removed: UseMovie()

FileSystem

added: FinishDirectory(#Directory)
added: DirectoryEntryType(#Directory)
added: DirectoryEntryDate(#Directory, DateType) - #PB_Date_Created, #PB_Date_Accessed, #PB_Date_Modified
added: GetFileDate(Filename$, DataType)
added: SetFileDate(Filename$, DataType)

changed: NextDirectoryEntry(#Directory) - new Parameter
changed: DirectoryEntryName(#Directory) - new Parameter
changed: DirectoryEntryAttributes(#Directory) - new Parameter
changed: DirectoryEntrySize(#Directory) - new Parameter
changed: IsFilename() to CheckFilename() - function name changed

removed: UseDirectory()

Important notes: NextDirectoryEntry() no longer returns the type of entry (file/type). To be consistent with other Examine...()/Next...() functions in PB, it now only returns 0 or 1 (0 means no more objects) Use DirectoryEntryType() to find out the type of entry like you did before with the result of NextDirectoryEntry(). FinishDirectory() has to be called after each ExamineDirectory().

Menu

added: GetMenuItemText(#Menu, ItemID)
added: GetMenuTitleText(#Menu, ItemID)
added: SetMenuItemText(#Menu, ItemID, Text$)
added: SetMenuTitleText(#Menu, ItemID, Text$)

changed: DisableMenuItem(#Menu, ItemID, State) - new Parameter
changed: MenuID(#Menu) - new Parameter

Console

added: EnableGraphicalConsole(State)
added: RawKey()
added: Redirection and standard output support

changed: Inkey() - now returns only 1 char or nothing (instead of always 2), use RawKey() for the extra character

Note: the old console lib used a graphical console mode, which did not output to stdout correctly. (you could not call it from commandline like: myprogram.exe > test.txt) Now you have the choice with EnableGraphicalConsole(State), and if you do not explicitly set the graphical mode, the printed stuff should be properly sent to stdout, enabling you to write better console tools. This also applies to stdin and the Input() command.

AudioCD

changed: all function name from 'CDAudio' to 'AudioCD' (less french-english..)

Toolbar

added: ToolBarHeight(#ToolBar)
added: ToolBarID(#ToolBar)

changed: ToolBarTooltip(#ToolBar, Button, Text$) - New parameter
changed: DisableToolBarButton(#ToolBar, Button, State) - New parameter

Statusbar

added: StatusBarHeight(#StatusBar)
added: StatusBarID(#StatusBar)

Font

changed: FontID(#Font) - New parameter
changed: CloseFont() to FreeFont()

removed: UseFont()

Preferences

added: ability to add/change/delete keys to existing prefs files.
added: RemovePreferenceKey(Name$)
added: RemovePreferenceGroup(Name$)
added: ExaminePreferenceGroups() - get all the group names in the file
added: NextPreferenceGroup() - go to the next group name. (the group will be set as the current one)
added: PreferenceGroupName() - get the group name.
added: ExaminePreferenceKeys() - get all key names in the current group
added: NextPreferenceKey() - go to the next key.
added: PreferenceKeyName() - get key name
added: ReadPreferenceQuad(Key$, Default)
added: ReadPreferenceDouble(Key$, Default)
added: WritePreferenceQuad(Key$, Value)
added: WritePreferenceDouble(Key$, Value)

Sprite

added: SpriteID(#Sprite)
added: FlipBuffer() - added a flag, to have a CPU optimized synchro in fullscreen mode

renamed: DisplayTranslucideSprite() to DisplayTranslucentSprite()

changed: TransparentSpriteColor(#Sprite, R, G, B) to TransparentSpriteColor(#Sprite, Color)
changed: ClearScreen(R, G, B) to ClearScreen(Color)

Library

renamed: IsFunction() -> GetFunction()

Network

added: UDP support trough the flags #PB_Network_UDP and #PB_Network_TCP
added: GetClientIP()
added: GetClientPort()
added: EventServerNumber()

renamed: NetworkClientID() -> EventClient()

Keyboard

added: #PB_Keyboard_International and #PB_Keyboard_AllowSystemKeys flags to KeyboardMode()

Clipboard

changed: GetClipboardData(Type) to GetClipboardImage(#Image)
changed: SetClipboardData(Type, Data) to SetClipboardImage(#Image)

Memory

added: Unicode conversion support to PeekS() and PokeS() between ascii, UTF8 and UTF16
added: PeekC(), PeekD(), PeekQ()
added: PokeC(), PokeD(), PokeQ()
added: MemorySize() - return size of a memory block
added: MoveMemory()
added: CompareMemoryString(*Text1, *Test2 [Mode [, MaxLength [, Flags]]]) - New flags parameter for UTF16/UTF8/Ascii compare
added: MemoryStringLength() - New flags parameter for UTF16/UTF8/Ascii support

Note: The commands PeekS, PokeS, CompareMemoryString, MemoryStringLength now have a parameter that specifies the string format. Possible options are: #PB_Ascii, #PB_Unicode or #PB_UTF8. This allows you do work with strings in memory independent of the actual String mode the executable was compiled with (unicode or not).

Engine3D

changed: CreateMesh(#Mesh, MaximumVertex) - new parameter
changed: MaterialAmbientColor(#Matrix1, -1) - -1 new parameter

added: EntityRenderMode()
added: WorldShadows(#PB_Shadow_Additive)
added: ParticleEmitterDirection()
added: GetEntityMass
added: SetEntityMass
added: GetEntityFriction
added: SetEntityFriction
added: EntityPhysicBody
added: ExamineWorldCollisions
added: NextWorldCollision
added: CheckWorldCollisionEntity
added: FirstWorldCollisionEntity
added: SecondWorldCollisionEntity
added: WorldGravity
added: EnableWorldCollision
added: EnableWorldPhysics
added: Parse3DScripts

removed: RotateParticleEmitter() (was useless for now)

Window

added: GetActiveWindow() - returns the Window with the focus
added: DisableWindow(#Window, State) - disable user input to a window
added: GetWindowState(#Window) - get minimized/maximized state
added: SetWindowState(#Window, State)- set minimized/maximized state
added: StickyWindow(#Window, State) - make the window stay on top of all others even if disabled
added: SetWindowColor(#Window, Color)- set background color of the window
added: GetWindowColor(#Window) - get the current background color of the window
added: SmartWindowRefresh(#Window, State) - enable or disable the smart refresh feature

changed: OpenWindow(#Window, x, y, Width, Height, Title$ [, Flags [, ParentID]]) - flags are now at the end and optionals
changed: WaitWindowEvent([Timeout]) - added optional timeout value
changed: ResizeWindow(#Window, x, y, width, height) - '-1' parameters must be changed to #PB_Ignore
changed: SetWindowCallback(@procedure()[, #Window]) - added optional window parameter (to set callback for 1 window only)
changed: ResizeWindow(#Window, x, y, Width, Height) - now same as ResizeGadget()
changed: WindowID(#Window) - parameter no longer optional
changed: WindowHeight(#Window) - new parameter
changed: WindowWidth(#Window) - new parameter
changed: WindowX(#Window) - new parameter
changed: WindowY(#Window) - new parameter
changed: WindowMouseX(#Window) - new parameter
changed: WindowMouseY(#Window) - new parameter
changed: WindowOutput(#Window) - new parameter

renamed: EventWindowID() to EventWindow()
renamed: EventGadgetID() to EventGadget()
renamed: EventMenuID() to EventMenu()
renamed: ActivateWindow() to SetActiveWindow(#Window)

removed: MoveWindow()
removed: DetachMenu()
removed: UseWindow()
removed: Compatibility constants like #PB_EventCloseWindow (use the documented #PB_Event_CloseWindow instead)

Gadget

added: GetActiveGadget() - returns the currently active Gadget
added: GadgetType(#Gadget) - returns a constant that identifies what kind of Gadget this is
added: SetGadgetData(#Gadget, Value) - associate a value with the Gadget (works for all Gadgets.)
added: GetGadgetData(#Gadget) - read the associated value
added: SetGadgetItemData(#Gadget, Item, Value) - associate value with gadget item (works for specific gadgets only)
added: GetGadgetItemData(#Gadget, Item)
added: SetGadgetColor(#Gadget, ColorType, Color)
added: GetGadgetColor(#Gadget, ColorType)
added: SetGadgetItemColor(#Gadget, Item, ColorType, color [, Column])
added: GetGadgetItemColor(#Gadget, Item, ColorType [, Column])

changed: ActivateGadget(#Gadget) is now SetActiveGadget(#Gadget)
changed: ResizeGadget(#Gadget, x, y, width, height), -1 should now be changed to #PB_Ignore

removed: #PB_String_MultiLine

Individual Gadget changes:

StringGadget()
- supports SetGadgetColor() for front and backcolor

TextGadget()
- Supports SetGadgetColor() for front and backcolor

ListViewGadget()
- Supports SetGadgetColor() for front and backcolor (not for individual items)
- Supports SetGadgetItemData()
- new Flags:
#PB_ListView_Multiselect - allow multi selection
#PB_ListView_ClickSelect - multiselect + clicking an item selects/deselects it

ComboBoxGadget()
- Supports SetGadgetItemData()

ListIconGadget()
- Supports SetGadgetColor() for front and backcolor and #PB_Gadget_LineColor (for #PB_ListIcon_GridLines)
- Supports SetGadgetItemColor() for front and backcolor (can be set for each cell individually)
- Supports SetGadgetItemData()
- The event to detected a checkbox change is now #PB_EventType_Change
- Supports GetGadgetItemAttribute(#Gadget, 0, #PB_ListIcon_ColumnWidth, 2) ; return width of column 2
- Supports SetGadgetItemAttribute(#Gadget, 0, #PB_ListIcon_ColumnWidth, 100, 2) ; set width of column 2 to 100
- Supports GetGadgetItemText(#Gadget, -1, 2) ; return header text for column 2
- Supports SetGadgetItemText(#Gadget, -1, "New Text", 2) ; change header text for column 2

HyperLinkGadget()
- Supports SetGadgetColor() for frontcolor (background is always transparent)
- new Flag: #PB_Hyperlink_Underline - draw a line under the text (without the need for an underlined font)

ContainerGadget()
- supports SetGadgetColor() for backcolor

ProgressBarGadget()
- supports SetGadgetColor() for front & backcolor (not working with XP skins)
- supports SetGadgetAttribute() with #PB_ProgressBar_Minimum, #PB_ProgressBar_Maximum

ScrollBarGadget()
- Supports SetGadgetAttribute() with #PB_ScrollBar_Minimum, #PB_ScrollBar_Maximum, #PB_ScrollBar_PageLength

ScrollAreaGadget()
- supports SetGadgetColor() for backcolor
- new Flag: #PB_ScrollArea_Center - when the inner size is smaller than the outer, the inner area will be centered automatically
- new options for SetGadgetAttribute(): #PB_ScrollArea_X/#PB_ScrollArea_Y to read/set the current scroll pos.
- now generates an event when being scrolled

CalendarGadget()
- supports SetGadgetColor() with the following colortypes:
#PB_Gadget_BackColor - background
#PB_Gadget_FrontColor - text to display days
#PB_Gadget_TitleBackColor - background of month title
#PB_Gadget_TitleFrontColor - text color of month title
#PB_Gadget_GreyTextColor - color for days not of the current month

DateGadget()
- supports SetGadgetColor() with the same values as CalendarGadget to color the drop-down calendar
- the input area can not be colored at this time

EditorGadget()
- supports SetGadgetColor for front & backcolor
- new Flag: #PB_Editor_ReadOnly
- supports SetGadgetrAttribute() with #PB_Editor_ReadOnly to get/set the readonly flag

TrackBarGadget()
- supports SetGadgetAttribute() with #PB_TrackBar_Minimum, #PB_TrackBar_Maximum

SpinGadget()
- supports SetGadgetColor for front & backcolor (to color the edit area)
- supports SetGadgetAttribute() with #PB_Spin_Minimum, #PB_Spin_Maximum
- New Flags:
#PB_Spin_ReadOnly - The StringGadget is not editable, the number is only changeable by the arrows
#PB_Spin_Numeric - The SpinGadget will automatically update the text with value of the state, so SetGadgetText is not needed.
- EventType values:
1 - the up button was pressed
-1 - the down button was pressed
#PB_EventType_Change - the text in the edit box was changed

TreeGadget()
- Supports SetGadgetColor() for front & backcolor & #PB_Gadget_LineColor
- Supports SetGadgetItemColor() for front & backcolor
- changed management of items completly. There are no longer any nodes, just a continuous list where each item has a "sublevel". The sublevels of all items define the tree structure like this:
   + sublevel 0
   +-+ sublevel 1
   | | sublevel 1
   | +-+ sublevel 2
   | | sublevel 1
   | sublevel 0              
- new parameter to AddGadgetItem: AddGadgetItem(#Gadget, Position, Text$ [, ImageID [, Flags]])
The "Flags" parameter is always required for TreeGadget and specifies the Sublevel in which to put this item.

To create the above tree, you do this:
   AddGadgetItem(#TreeGadget, -1, "sublevel 0", 0, 0)
   AddGadgetItem(#TreeGadget, -1, "sublevel 1", 0, 1)
   AddGadgetItem(#TreeGadget, -1, "sublevel 1", 0, 1)
   AddGadgetItem(#TreeGadget, -1, "sublevel 2", 0, 2)
   AddGadgetItem(#TreeGadget, -1, "sublevel 1", 0, 1)
   AddGadgetItem(#TreeGadget, -1, "sublevel 0", 0, 0)    
- new GetGadgetItemAttribute() with #PB_Tree_SubLevel (readonly) to get the sublevel of any item
- removed: OpenTreeGadgetNode()
- removed: CloseTreeGadgetNode()
- removed: TreeGadgetItemNumber() - can be easily emulated by GadgetItemID() + a run trough the item list
- removed: CountTreeGadgetNodeItems() - can be easily emulated by comparing the sublevel of the items

PanelGadget()
- added GetGadgetAttribute() with #PB_Panel_ItemWidth, #PB_Panel_ItemHeight (readonly) (there must be at least 1 tab in the panel for this to work)

SplitterGadget()
- new flags for Get/SetGadgetAttribute(): #PB_Splitter_FirstGadget, #PB_Splitter_SecondGadget
With GetGadgetAttribute(), they return the #Gadget Number of the stored Gadget
With SetGadgetAttribute(), you can place a new Gadget in the Splitter.

Note: The old Gadget will not be automatically freed! (it will be put out of the splitter and on the same window as the splitter) So if you do not want the old gadget to remain, remove it with FreeGadget() This allows you to switch Gadgets in a splitter without the need to re-create any of them.

Note: You cannot have a Gadget in 2 Splitters at once. So to move a Gadget from one splitter to another, replace it in the first splitter first, and then put it in the second one.

MDIGadget()
- The child windows of the MDIGadget are no longer "GadgetItems", but real PB Windows. This means that you can use ANY command from the WindowLib with them (except StickyWindow()). This makes some of the MDIGadget features obsolete, therefore there are some changes:
- The Gadget no longer sends any events: all close, resize, activate events are received as Window events
- GetGadgetAttribute(), Get/SetGadgetItemAttribute, Get/SetGadgetItemState(), Get/SetGadgetItemText are all no longer supported. All this can be easily done through the Window lib commands.
- RemoveGadgetItem() no longer supported, use CloseWindow().

The Commands useable with MDIGadget now are only these: (+ the whole windowlib!)
- ClearGadgetItemList() : closes all child windows
- CountGadgetItems() : get the number of child windows in the gadget
- GetGadgetState() : get the WindowID of the Window currently in the foreground of the gadget
- SetGadgetState() : set a specific window to the foreground or arrange the child windows (All like the old MDIGadget)
- AddGadgetItem() : create an MDI Child: works like this:
   AddGadgetItem(#MDI, #Window, Title$ [, ImageID [, Flags]])
     - #Window - Number for the new window (can be #PB_Any!)
     - Title$  - new window title
     - ImageID - Icon for the window (optional)
     - Flags   - Supports most of the flags for OpenWindow, if none are specified, the default MDI flags are used. 
   Unsupported Flags: #PB_Window_Borderless, #PB_Window_ScreenCentered, #PB_Window_WindowCentered
Note: you must now call CreateGadgetList() to add items to a MDI child, just like with normal windows.

- SetGadgetColor() can be used with #PB_Gadget_BackColor to set the MDI backcolor
- SetGadgetAttribute() can be used with #PB_MDI_Image to set a background image, #PB_MDI_TileImage can set the tile mode of the image on or off

ExplorerListGadget()
- supports SetGadgetColor() for front & backcolor & #PB_Gadget_LineColor
- Supports GetGadgetItemAttribute(#Gadget, 0, #PB_Explorer_ColumnWidth, 2) ; return width of column 2
- Supports SetGadgetItemAttribute(#Gadget, 0, #PB_Explorer_ColumnWidth, 100, 2) ; set width of column 2 to 100
- Supports GetGadgetItemText(#Gadget, -1, 2) ; return header text for column 2
- Supports SetGadgetItemText(#Gadget, -1, "New Text", 2) ; change header text for column 2

ExplorerTreeGadget()
- supports SetGadgetColor() for front & backcolor & #PB_Gadget_LineColor