Global NewMap test()
For i = 0 To 9
r = Random(100)
test(Str(r)) = r
Next
ForEach test()
Debug "check element "+MapKey(test())
If test() > 50
DeleteMapElement(test(), MapKey(test()))
EndIf
Next
Debug "---"
ForEach test()
Debug MapKey(test())
Next
As soon as the first element is deleted, the ForEach loop just exists.
Programming on Windows 10 Pro / Windows 7 Enterprise / Linux Mint 19 / Manjaro Linux with PB 5, Python 3 and Go
Global NewMap test()
For i = 0 To 9
r = Random(100)
test(Str(r)) = r
Next
ForEach test()
Debug "check element "+MapKey(test())
If test() > 50
DeleteMapElement(test())
EndIf
Next
Debug "---"
ForEach test()
Debug MapKey(test())
Next
So in short, it is not possible to delete MapElements by stating their "Key$" in a ForEach?
Unfortunately, I have to rewrite a bunch of code to get around this in the real project (obviously not the short example code).
Programming on Windows 10 Pro / Windows 7 Enterprise / Linux Mint 19 / Manjaro Linux with PB 5, Python 3 and Go
Global NewMap test()
For i = 0 To 9
r = Random(100)
test(Str(r)) = r
Next
ForEach test()
Debug MapKey(test())
Next
ForEach test()
PushMapPosition(test())
While NextMapElement(test())
If test() > 50
DeleteMapElement(test())
EndIf
Wend
PopMapPosition(test())
Next
; "--- NECESSARY EVIL because we skipped first element do test on first again"
ResetMap(test())
NextMapElement(test())
If test() > 50
DeleteMapElement(test())
EndIf
Debug "---"
ForEach test()
Debug MapKey(test())
Next
Norm.
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari