@Alexi : though that does the job, it's wasting memory and time !
@STARGÅTE : thanks for posting this, it will save me great time
@freak : indeed it could be used ! I stumbled on this post because just now I had the problem gnasen had.
I use list of pointer for a long time, et a lot to sort things stored in another place :
On one side I have the resources with all the data
and on the other side the list that address the data in a specified order.
And on my case it took time for me to find the problem because the error was not found by the compiler.
Cause I put it like that :
Code: Select all
Structure my_test
List test.POINT()
List *pt_test.POINT()
EndStructure
Define VAR_glb.my_test
InitializeStructure(VAR_glb, my_test)
For a = 0 To 100 Step 20
AddElement(VAR_glb\test())
AddElement(VAR_glb\pt_test())
VAR_glb\test()\x = a
VAR_glb\pt_test() = VAR_glb\test()
Next
For a = -100 To 0 Step 20
AddElement(VAR_glb\test())
AddElement(VAR_glb\pt_test())
VAR_glb\test()\x = a
VAR_glb\pt_test() = VAR_glb\test()
Next
SortStructuredList(VAR_glb\test(), #PB_Sort_Descending, OffsetOf(POINT\x), #PB_Long)
ForEach VAR_glb\test()
Debug VAR_glb\test()\x
Next
Debug "----"
ForEach VAR_glb\pt_test()
Debug VAR_glb\pt_test()\x
Next
Debug "####"
SortStructuredList(VAR_glb\pt_test(), #PB_Sort_Descending, OffsetOf(POINT\x), #PB_Long)
ForEach VAR_glb\test()
Debug VAR_glb\test()\x
Next
Debug "----"
ForEach VAR_glb\pt_test()
Debug VAR_glb\pt_test()\x
Next
this is an example code, so there is a reason I coded it that way in my project.