Peek / Poke newbie

Blitz3D Forums/Blitz3D Beginners Area/Peek / Poke newbie

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

The easiest option for storing types are arrays (for me anyway).

There are many topics related to arrays of types.

And you cannot ever miscalculate the offset when using arrays.

A quick example:
; Create a window of size 800x600
Graphics 800, 600, 0, 2

; Create the type and add fields to it
Type MyType
	Field x%, y%
End Type

; Create an array with the name "MyArray", tell it to hold pointers to the type "MyType"
; (as you would tell an array to hold strings: Dim MyArray$(10)) and give it 11 indexes (0 - 10)
Dim MyArray.MyType(10)

; Now create all type instances and put their pointer into the array
For i = 0 To 10
	MyArray(i) = New MyType
Next

; Put some data into it
For i = 0 To 10
	MyArray(i)\x% = i
	MyArray(i)\y% = i * 2
Next

; Print all data
For i = 0 To 10
	Print i + ": " + MyArray(i)\x% + ", " + MyArray(i)\y%
Next

; Wait for a keypress to close the window
WaitKey()
End