[Implemented] ListSize

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User_Russian
Addict
Addict
Posts: 1520
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

[Implemented] ListSize

Post by User_Russian »

From help
safely used to determine if a list is empty or not.
Using the function is not safe! The application is crashing.

Code: Select all

DisableDebugger
NewList x()
FreeList(x())
MessageRequester("", Str(ListSize(x())))
normeus
Enthusiast
Enthusiast
Posts: 470
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: ListSize

Post by normeus »

if you might use the list again use:

Code: Select all

ClearList(x())
It frees memory like FreeList() but the List reference is still available. FreeList() makes it like the variable never existed.


Norm.
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
infratec
Always Here
Always Here
Posts: 7588
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: ListSize

Post by infratec »

if a list is empty or not
After FreeList() you have no list. So it is correct.
It is not a procedure to test if a list is available or not.
infratec
Always Here
Always Here
Posts: 7588
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: ListSize

Post by infratec »

Maybe a FeatureRequest for IsList() is a good idea.
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: ListSize

Post by STARGÅTE »

I would prefer that ListSize() gives -1 if the list is not initialized, as it is the behavior for arrays.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
Denis
Enthusiast
Enthusiast
Posts: 778
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Re: ListSize

Post by Denis »

STARGÅTE wrote: Wed Oct 12, 2022 10:19 pm I would prefer that ListSize() gives -1 if the list is not initialized, as it is the behavior for arrays.
+1
A+
Denis
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2137
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Re: ListSize

Post by Andre »

Moved to 'Feature requests'
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
Post Reply