Persistent Variables during recursion

Pete pete at mollysrevenge.com
Thu Jan 26 15:50:07 EST 2012


You need to pass the persistent variables as parameters to the recursive
function.  When you call the function for the first time, just make sure
the variables are empty, then when you call it from within itself, they'll
get passed with whatever the values are at the time of the call.
Pete

On Thu, Jan 26, 2012 at 12:04 PM, Bob Sneidar <bobs at twft.com> wrote:

> Hi all. This is my first foray into recursive functions. There are two
> variables I would like to be persistent for as long as the script is
> running, but I want them to be empty the first time I call the recursive
> function. I have tried declaring the variables as local, but each time the
> function calls itself, the variables are wiped as though a new set is made.
> If I declare them as global, then of course the value persists even after
> the last recursion terminates. The function has no idea if it is  the first
> time through or one of the iterations. Any idea how to get around this?
>
> Bob
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>


-- 
Pete
Molly's Revenge <http://www.mollysrevenge.com>



More information about the use-livecode mailing list