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: 1431
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

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...
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
BarryG
Addict
Addict
Posts: 3292
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: 1431
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: Clear for fast clearing variables

Post by jacdelad »

Yes, I could. But I don't want to. Clear would be a bit handier.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Post Reply