Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 3121 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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 )
)

 

Posted (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 by comment
Posted

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 )
)

 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.