Page 1 of 1

DeleteElement() return value as official feature

Posted: Tue Oct 15, 2013 1:39 am
by Regenduft
At the moment DeleteElement() is returning non-zero if there is a current element after deleting and it is returning zero if there is no current element after deleting.

PureBasics help file says, that DeleteElement() has no return value. Since the (de facto) return value is very useful, it would be nice to make it an official feature, so you can rely on it.

Code: Select all

NewList a()
Debug AddElement(a())    ; = 31202064
Debug AddElement(a())    ; = 31202096
Debug AddElement(a())    ; = 31202128
Debug ""
Debug DeleteElement(a()) ; = 31202112
Debug DeleteElement(a()) ; = 31202080
Debug DeleteElement(a()) ; = 0
Debug ""
Debug DeleteElement(a()) ; = 0

Code: Select all

NewList a()
Debug AddElement(a())    ; = 29891344
Debug AddElement(a())    ; = 29891376
Debug AddElement(a())    ; = 29891408
Debug ""
FirstElement(a())
Debug DeleteElement(a()) ; = 0
Debug DeleteElement(a()) ; = 0
;...

Re: DeleteElement() return value as official feature

Posted: Tue Oct 15, 2013 3:31 pm
by freak
At the moment you cannot rely on it. The C function is defined as "void", so the return value is whatever was left in the 'eax' (or rax) register when the function exited. This is not reliable.