Welcome to Pauls PureProject
 Home Online Reference Guide duplicated from http://cvs.purebasic.com  
 Online Resources
   · Reference

 Libraries
     2DDrawing
     Billboard
     Camera
     CDAudio
     Cipher
     Clipboard
     Console
     Database
     Date
     Desktop
     Engine3D
     Entity
     File
     FileSystem
     Font
     Gadget
     Help
     Image
     ImagePlugin
     Joystick
     Keyboard
     Library
     Light
     LinkedList
     Material
     Math
     Memory
     Menu
     Mesh
     Misc
     Module
     Mouse
     Movie
     Network
     OnError
     Packer
     Palette
     Particle
     Preference
     Printer
     Requester
     Sort
     Sound
     SoundPlugin
     Sprite
     Sprite3D
     StatusBar
     String
     SysTray
     Terrain
     Texture
     Thread
     Toolbar
     Window

 Structures


Syntax
Structure <name> [Extends <name>]
  ...
EndStructure 
Description
Structure is useful to define user type, and access some OS memory areas. Structures can be used to enable faster and easier handling of data files. It is very useful as you can group into the same object the informations which are common. Structures fields are accessed with the \ option. Structures can be nested. Statics arrays are supported inside structures.

The optionnal Extends parameter allows to extends another structure with new fields. All fields found in the extended structure will be available in the new structure and will be placed before the new fields. This is useful to do basic inheritance of structures.

SizeOf can be used with structures to get the size of the structure and OffsetOf can be used to retrieve the index of the specified field.

Please note, that in structures a static array[] doesn't behave like the normal BASIC array (defined using Dim) to be conform to the C/C++ structure format (to allow direct API structure porting). This means that a[2] will allocate an array from 0 to 1 where Dim a(2) will allocate an array from 0 to 2.

Example:

  Structure Person
    Name.s
    ForName.s 
    Age.w 
  EndStructure

  Dim MyFriends.Person(100)

  ; Here the position '0' of the array MyFriend()
  ; will contain one person and it's own informations

  MyFriends(0)\Name = "Andersson"
  MyFriends(0)\Forname = "Richard" 
  MyFriends(0)\Age = 32

Example: A more complex structure (Nested and static array)

  Structure Window
    *NextWindow.Window  ; Points to another window object
    x.w 
    y.w
    Name.s[10]  ; 10 Names available (from 0 to 9)
  EndStructure

Example: Extended structure

  Structure MyPoint
    x.l 
    y.l
  EndStructure

  Structure MyColoredPoint Extends MyPoint
    color.l 
  EndStructure

  ColoredPoint.MyColoredPoint\x = 10
  ColoredPoint.MyColoredPoint\y = 20
  ColoredPoint.MyColoredPoint\color = RGB(255, 0, 0)

Syntax
StructureUnion
  Field1.Type
  Field2.Type
  ...
EndStructureUnion
Description
Structure union are only useful for advanced programmers which want to save some memory by sharing some fields inside the same structure. It's like the 'union' keyword in C/C++.

Example:

  Structure Type
    Name$
    StructureUnion
      Long.l      ; Each field (Long, Float and String) resides at the
      Float.f     ; place in memory.
      String.s    ;
    EndStructureUnion
  EndStructure



Hosted by Reel Media Productions Copyright©2001-2004 All Rights Reserved