chi wrote:
This is fantastic! Thank you, idle

Now I can finally get rid of converting the hWnd to a string first...
try this, think I've got it sorted so you can use native types but might not work on osx
Code:
;NumericMap hack for structured Numeric keyed Maps
;windows linux osx
Import ""
PB_NewNumericMap(ElementSize.i,*StructureMap,*Address,HashTabelSize.l);
PB_FreeMap(*Map) ;
PB_ResetMap(*Map) ;
PB_ClearMap(*Map) ;
PB_MapSize(*Map) ;
PB_PushMapPosition(*map) ;
PB_PopMapPosition(*map) ;
PB_NextMapElement(*Map) ;
PB_FindNumericMapElement(*Map,Key.i) ;
PB_AddNumericMapElement(*Map,Key.i) ;
PB_AddNumericMapElement2(*Map,Key.i,ElementCheck=#PB_Map_ElementCheck);
PB_DeleteNumericMapElement2(*Map,Key.i) ;
PB_DeleteNumericMapElement(*Map) ;
PB_CopyMap(*Map,*DestinationMap) ;
PB_CopyMap2(*Map,*DestinationMap,Clear.l) ;
EndImport
Macro NewNumericMap(pmap,HashTableSize,StructureType,IsStructure=0)
Global structadr=0
EnableASM
CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
CompilerIf IsStructure
lea rax,[s_#StructureType]
mov [v_structadr],rax
CompilerEndIf
CompilerElse
CompilerIf IsStructure
lea eax,[s_#StructureType]
mov [v_structadr],eax
CompilerEndIf
CompilerEndIf
DisableASM
PB_NewNumericMap(SizeOf(StructureType),structadr,@pmap,HashTableSize)
EndMacro
Procedure NumericMapkey(*Map)
Protected ele,key
ele = PeekI(*map)
key = PeekI(ele+SizeOf(Integer))
ProcedureReturn key
EndProcedure
CompilerIf #PB_Compiler_IsMainFile
;Note you need to use a structured element pointer even for native types
Structure foo
List controls.i()
i.i
s.s
EndStructure
Procedure test()
Protected mp, *el.foo
NewNumericMap(mp,512,foo,#PB_Structure) ;create the map and pass map variable, number of elements, the name of the structure
*el = PB_AddNumericMapElement(mp,123)
AddElement(*el\controls())
*el\controls() = 111
AddElement(*el\controls())
*el\controls() = 112
*el\i = 123
*el\s = "Hello"
;
*el = PB_AddNumericMapElement2(mp,345)
AddElement(*el\controls())
*el\controls() = 113
AddElement(*el\controls())
*el\controls() = 114
*el\i = 345
*el\s = "World"
;
*el = PB_FindNumericMapElement(mp,123)
ForEach *el\controls()
Debug "list Controls " + *el\controls()
Next
Debug "integer " + *el\i
Debug "string " + *el\s
*el = PB_FindNumericMapElement(mp,345)
ForEach *el\controls()
Debug "list Controls " + *el\controls()
Next
Debug "integer " + *el\i
Debug "string " + *el\s
Debug "+++++++++++"
Debug "walk the map"
Debug "+++++++++++"
PB_ResetMap(mp)
Repeat
*el = PB_NextMapElement(mp)
If *el
Debug "mapkey " + NumericMapkey(mp)
ForEach *el\controls()
Debug "list Controls " + *el\controls()
Next
Debug "integer " + *el\i
Debug "string " + *el\s
EndIf
Until *el=0
Debug "++++++++++++++"
Debug "clear map"
PB_ClearMap(mp);
PB_ResetMap(mp)
Repeat
*el = PB_NextMapElement(mp)
If *el
Debug "mapkey " + NumericMapkey(mp)
ForEach *el\controls()
Debug "list Controls " + *el\controls()
Next
Debug "integer " + *el\i
Debug "string " + *el\s
EndIf
Until *el=0
Debug "should be nothing"
PB_FreeMap(mp)
Debug "++++++++++++"
Debug "test with a native type via pointer"
Protected *elf.float
NewNumericMap(mp,512,float) ;create the map and pass map variable, number of elements, the name of the structure
*elf = PB_AddNumericMapElement(mp,123)
*elf\f = #PI
*elf = PB_AddNumericMapElement(mp,345)
*elf\f = 2*#PI
*elf = PB_FindNumericMapElement(mp,123)
Debug *elf\f
*elf = PB_FindNumericMapElement(mp,345)
If *elf
Debug *elf\f
EndIf
Debug NumericMapkey(mp)
PB_FreeMap(mp)
EndProcedure
test()
CompilerEndIf