GetListPositionStackSize(MyList())

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
jacdelad
Addict
Addict
Posts: 1993
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

GetListPositionStackSize(MyList())

Post by jacdelad »

Hello,
I know, I can do this by using a variable to keep track on, but I'd wish to see a builtin function to determine how many elements are currently on the stack used with PushListPosition(List())/PopListPosition(MyList()). This would be more comfortable.
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
User avatar
Bisonte
Addict
Addict
Posts: 1305
Joined: Tue Oct 09, 2007 2:15 am

Re: GetListPositionStackSize(MyList())

Post by Bisonte »

Interesting !

I always thought it was only possible with one element at a time....

But it seems not.

Code: Select all

NewList a()

For i = 1 To 10
  AddElement(a()) : a() = i
Next i  

ForEach a()
  If a() > 2 And a() < 6 
    PushListPosition(a())
  EndIf
Next

For i = 1 To 3
  PopListPosition(a())
  Debug a()
Next i
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: GetListPositionStackSize(MyList())

Post by Little John »

Bisonte wrote: Thu Feb 08, 2024 8:03 am Interesting !

I always thought it was only possible with one element at a time....
Here is detailed information about PushListPosition() and PopListPosition() by freak.

PS: A new built-in function GetListPositionStackSize() is overkill IMHO. Using a variable for this purpose is easy.
User avatar
jacdelad
Addict
Addict
Posts: 1993
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: GetListPositionStackSize(MyList())

Post by jacdelad »

...and as you can see, I read it some time ago. :mrgreen:
However, the positions themselves are surely stored in some list internally and while we totally can use a variable to keep track on the stack size, it should be just a few lines to fulfill my request.
However again, I'm not mad if this doesn't become a thing. I could use it right now and...you guessed it...I am using variable right now.
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: GetListPositionStackSize(MyList())

Post by Little John »

jacdelad wrote: Thu Feb 08, 2024 7:37 pm ...and as you can see, I read it some time ago. :mrgreen:
So what? My above link to freaks post obviously was for Bisonte, not for you. :mrgreen:
Post Reply