Clear for fast clearing variables

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

Clear for fast clearing variables

Post by jacdelad »

Hello,
I'd like to see a new command, Clear. I know this from other languages, used for fast clearing a bunch of variables at once:

Code: Select all

Define first.s,second$,third.l,fourth.i,NewList MyList.s(),NewMap MyMap.l()
;Do stuff and fill variables, lists, etc.
Clear first,second$,third,fourth,MyList(),MyMap()
...would set strings to length 0, all other variables to 0, lists and maps emptied.

Just a suggestion...
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
BarryG
Addict
Addict
Posts: 4134
Joined: Thu Apr 18, 2019 8:17 am

Re: Clear for fast clearing variables

Post by BarryG »

jacdelad wrote: Fri Aug 27, 2021 10:50 pmwould set strings to length 0, all other variables to 0, lists and maps emptied

Code: Select all

first=0 : second$="" : FreeList(MyList()) : FreeMap(MyMap()) ...
Why not just do this?
User avatar
jacdelad
Addict
Addict
Posts: 1993
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: Clear for fast clearing variables

Post by jacdelad »

Yes, I could. But I don't want to. Clear would be a bit handier.
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
Post Reply