Push.. and PopMapPosition() doesn't work with FindMapElement

Found an issue in SpiderBasic ? Please report it here !
User avatar
Posts: 85
Joined: Mon May 26, 2014 9:33 am

Push.. and PopMapPosition() doesn't work with FindMapElement

Post by Kurzer »

PopMapPosition() doesn't restore the previous MapElement after using FindMapElement().

Code example:

Code: Select all


Define.s sCurrentID, sCurrentValue, sAnotherValue

NewMap Numbers.s()
  Numbers("1") = "I am 1"
  Numbers("2") = "I am 2"
  Numbers("3") = "I am 3"
  Numbers("4") = "I am 4"
  Numbers("5") = "I am 5"
  sCurrentID = "3"
  If FindMapElement(Numbers(), sCurrentID)
  	sCurrentValue = Numbers()
  	Debug "Current value: " + sCurrentValue
  	FindMapElement(Numbers(), "5")
  	sAnotherValue = Numbers()
  	Debug "Another value: " + sAnotherValue
  	sCurrentValue = Numbers()
  	Debug "Back to current value: " + sCurrentValue
  	Debug "Should be 'I am 3', but is still 'I am 5'"

Code: Select all

Current value: I am 3
Another value: I am 5
Back to current value: I am 5
Should be 'I am 3', but is still 'I am 5'
It doesn't explicitly say in the help that you can use this together with FindMapElement(), but I don't understand why it matters how the pointer to the current MapElement was changed.

I thought until now that the value of the map pointer is simply pushed onto the stack and later taken down again to restore the current map pointer with it.

SB 2.32 x86, Browser: Iron Portable V. 88.0.4500.0 (Chromium based), User age: 53y
"Happiness is a pet." | "Never run a changing system!"