1 Attachment(s)
another test... and some Error
Got an Error! But not related to the current topic but while experimenting with new tB-functions.
This is my testing script, requires the heap-unit below and thinCore.dll above anyway since the unit makes use of the new Array Scan Ptr-functionality
Code:
Uses "console"
#INCLUDE "Heap.tBasicU"
' some simple udt for test
Type t_vec3d
X As Double
Y As Double
Z As Double
SetPos As Function
End Type
Function t_Vec3d.SetPos(ByVal X As Double, ByVal Y As Double, ByVal Z As Double)
Me.X = X
Me.Y = Y
Me.Z = Z
End Function
' ---------------
Dim foo As Heap
' create some space to store different things at foo
foo.AllocLike("Heap", 3)
' first heap at foo shall contain a string
Dim vHeap Like foo.GetType At foo.pData
vHeap.Be("Hello World", "String")
' next heap at foo shall contain some longs
SetAt(vHeap, VarPtr(vHeap) + SizeOf(vHeap))
vHeap.Be(MKL$(1,2,3,4,5), "Long")
' next heap at foo shall contain 3 vecs
SetAt(vHeap, VarPtr(vHeap) + SizeOf(vHeap))
vHeap.allocLike("t_Vec3d", 3)
' fill in some udt-data
Dim vVec Like vHeap.GetType At vHeap.pData
vVec.SetPos(1.1, 1.2, 1.3)
SetAt( vVec, VarPtr(vVec)+ SizeOf(vVec) )
vVec.SetPos(2.1, 2.2, 2.3)
SetAt( vVec, VarPtr(vVec)+ SizeOf(vVec) )
vVec.SetPos(3.1, 3.2, 3.3)
' now reset to first heap
SetAt( vHeap, foo.pData )
While VarPtr(vHeap) < foo.GetEnd
PrintL "Type is " & vHeap.GetType
' replace below
' "HEAP_Get(vHeap.pType)" with "vHeap.GetType()" to have error
'the following line is the one:
Select Case HEAP_Get(vHeap.pType)
Case "STRING"
PrintL "contains :" & vHeap.Is
Case "LONG"
Dim vLong As Long At vHeap.pData
While VarPtr(vLong) < vHeap.GetEnd
PrintL vLong
SetAt(vLong, VarPtr(vLong) + SizeOf(Long))
Wend
Case "T_VEC3D"
SetAt(vVec, vHeap.pData)
While VarPtr(vVec) < vHeap.GetEnd
PrintL "X:" & vVec.X
PrintL "Y:" & vVec.Y
PrintL "Z:" & vVec.Z
SetAt(vVec, VarPtr(vVec) + SizeOf(vVec))
Wend
End Select
' push forward to next heap
SetAt(vHeap, VarPtr(vHeap) + SizeOf(vHeap) )
Wend
PrintL $CRLF & Repeat$(42, "*")
PrintL $CRLF & "Any key to end"
WaitKey
check line 53 of the script.
Code:
Select Case [some type-function-result]
results in crash, no matter if parenthesis used or not. I don't know if that is always the case since i discovered this as a reason of error for the first time