any way to clear all local variables at start of program

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
PoLyGLoT
Posts: 105
Joined: Sat Jan 14, 2012 12:37 am

any way to clear all local variables at start of program

Post by PoLyGLoT » Fri Aug 16, 2013 4:15 pm

Hi all,

I use a lot of local variables in my programming. Instead of writing out "put empty into X" 50 times (1 for each variable), is there any way to put empty into all local variables at the start of a handler?

Thanks so much!!

PoLyGLoT
Posts: 105
Joined: Sat Jan 14, 2012 12:37 am

Re: any way to clear all local variables at start of program

Post by PoLyGLoT » Fri Aug 16, 2013 4:48 pm

Greetings all,

I may have answered my own question. I realized that if you put:

local var1,var2,var3, etc.....

at the top of your handler, it will automatically clear them once it exits / re-enters said handler.

However, it would be nice to have a command to flush all local variables at the end of a handler just to be super duper sure they are all flushed out. Any such command?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10364
Joined: Wed May 06, 2009 2:28 pm

Re: any way to clear all local variables at start of program

Post by dunbarx » Sat Aug 17, 2013 4:18 am

Hi.

Local variables are deleted from memory when the handler ends.

But there is a function, "the variableNames", that might be used to do what you want. You can take the list generated from that and clear whatever you want to,

Craig Newman

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7395
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: any way to clear all local variables at start of program

Post by jacque » Sat Aug 17, 2013 6:40 pm

You don't even need to declare the variables in the handler if you don't want to. Variables are never preserved when the handler terminates. There's no need to remove them or worry about their memory usage. They always go poof.

In fact, the usual problem is that people wonder where the values went when the handler ends. :)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply