a parameter for ResetList() to seek behind end

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
#NULL
Addict
Addict
Posts: 1497
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

a parameter for ResetList() to seek behind end

Post by #NULL »

..optional, something like ResetList(list(),-1).
would be nice for reverse iterating with While
#NULL
Addict
Addict
Posts: 1497
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Post by #NULL »

why does ChangeCurrentElement() not return something usefull, like the former element.
then instead of that

Code: Select all

*remember = @list()
  ChangeCurrentElement(list(),*parent)
  ;...do something at another position
ChangeCurrentElement(list(),*remember)
you could write

Code: Select all

*remember = ChangeCurrentElement(list(),*parent) ; returns the address of the former element
  ;...do something at another position
ChangeCurrentElement(list(),*remember)
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Post by nco2k »

> ResetList(list(),-1)
well, it would be usefull if PreviousElement() would automatically jump to the last element if there is no current element selected (-1). no need for an extra flag in ResetList() imo.

> ChangeCurrentElement()
yes, thats something i also noticed. would be cool if it would return the pointer of the former element, but only if the change was successfull, otherwise return 0.

and also a #True/#False for SwapElements() maybe? in case of an invalid pointer, instead of an invalid memory access error. just an idea.

c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Hurga
Enthusiast
Enthusiast
Posts: 148
Joined: Thu Jul 17, 2003 2:53 pm
Contact:

Post by Hurga »

I think it qould be very useful to have a way to check if there was a invalid pointer given.

maxbe with a returnvalue of changecurrentelement
I can think as an other way to set Listindex(<Listname>) to -1. (currently it keeps the last element AFAIK)
This would prevent an IMA.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

why does ChangeCurrentElement() not return something usefull, like the former element.
I think this is a great idea. :)
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Post Reply