May 6, 20169 yr 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 ) )
May 6, 20169 yr 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, 20169 yr by comment
May 6, 20169 yr 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 ) )
Create an account or sign in to comment