fb:porticula NoPaste
Store pointer in UDT
Uploader: | Sebastian |
Datum/Zeit: | 12.05.2013 13:25:03 |
TYPE tNebulaPolygon
objectName As String
numCoordinates As Integer
coordinates As Integer Ptr
END TYPE
DIM x AS tNebulaPolygon
x.objectName = "Big green nebula"
x.numCoordinates = 100
x.coordinates = CAllocate(SizeOf(Integer) * x.numCoordinates * 2)
Dim As Integer ptr currentPointer = x.coordinates
Dim As Integer i
Randomize Timer
For i = 1 To x.numCoordinates*2
*(currentPointer) = Int( Rnd * 1000 )
currentPointer += SizeOf(Integer)
Next i
' Data generation finished.
' Display data:
Print "Coordinates of " & chr(34) & x.objectName & chr(34)
Dim As Integer cx, cy
currentPointer = x.coordinates 'Beginning of buffer
For i = 1 To x.numCoordinates
cx = *(currentPointer)
currentPointer += 4
cy = *(currentPointer)
currentPointer += 4
PRINT "Pair " & i & ": (X,Y) = (" & cx & "," & cy & ")"
Next i
Sleep