Skip to main content
1-Visitor
July 8, 2013
Solved

Need help making a for loop counter

  • July 8, 2013
  • 2 replies
  • 1618 views

I'm made a double for leep for a Mathcad sheet and I'm trying to add a variable that counts the total number of times the program loops. For example, if I have 2 for loops, both of them from 0 to two, then the total number of times the program lops is four.

Does anyone kow how to do this?

Best answer by Werner_E

Leopoldo Vasquez wrote:

I'm made a double for leep for a Mathcad sheet and I'm trying to add a variable that counts the total number of times the program loops. For example, if I have 2 for loops, both of them from 0 to two, then the total number of times the program lops is four.

Does anyone kow how to do this?

Sure.

You could add an additional variable which is set to zero at the beginning of the program and incremented every time the "program loops".

For further help please post your worksheet.

BTW, in the example you gave, I would expect the result nine, if the loops are nested and six, if they are written one after the other, but not four (unless you change the default stepwith one, of course).

2 replies

Werner_E25-Diamond IAnswer
25-Diamond I
July 8, 2013

Leopoldo Vasquez wrote:

I'm made a double for leep for a Mathcad sheet and I'm trying to add a variable that counts the total number of times the program loops. For example, if I have 2 for loops, both of them from 0 to two, then the total number of times the program lops is four.

Does anyone kow how to do this?

Sure.

You could add an additional variable which is set to zero at the beginning of the program and incremented every time the "program loops".

For further help please post your worksheet.

BTW, in the example you gave, I would expect the result nine, if the loops are nested and six, if they are written one after the other, but not four (unless you change the default stepwith one, of course).

1-Visitor
July 8, 2013

Thank you,

That's exactly what I did.