James Gill Posted May 6, 2016 Posted May 6, 2016 I’m trying to make a recursive function that counts to 10 and stops. Right now it just keeps counting. What am I doing wrong? MyCounter ( Number): Let ( [ $i = $i + 1 ]; Case ( $i < 10 ; MyCounter ( $i ) ; $i ) )
comment Posted May 6, 2016 Posted May 6, 2016 (edited) I am not sure what you mean by "keeps counting". I am pretty sure you need to reset $I to 0 or empty at the end of the function, otherwise the next call will start from 10 (and then from 11, 12, etc. - until you close the file). I would also suggest you avoid using $variables or $$variables in a custom function if possible - and it's certainly possible here. You have a parameter that you're not using at all. Call the function with a parameter of 10 and count down until it's depleted. Or call it with a parameter of 0 (or empty) and count up until it reaches 10. Edited May 6, 2016 by comment
rwoods Posted May 6, 2016 Posted May 6, 2016 Hello Maybe it's because you aren't accessing the parameter at all? Try... MyCounter ( Number): Let ( [ $i = Number + 1 ]; Case ( $i < 10 ; MyCounter ( $i ) ; $i ) )
Recommended Posts
This topic is 3121 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now