Skip to main content
23-Emerald V
September 17, 2024
Solved

Using a variable in a loop before it is defined?

  • September 17, 2024
  • 1 reply
  • 679 views

Whilst looking at another worksheet in Mathcad Prime 10, I noticed that an as-yet undefined variable in a loop had a value (albeit zero)

 

2024 09 17 B.png

 

I can't remember if this was standard behaviour in previous versions of Mathcad or not.   However, it certainly caused me some moments of pondering whilst I tried to determine how a variable was initialized in a much longer program (that I was trying to understand in the first place!).

 

Stuart

Best answer by Werner_E

The behaviour is the same in MC15 and it seems that any loop does the trick

Werner_E_0-1726575440223.png

 

Werner_E_1-1726575470342.png

 

1 reply

Werner_E25-Diamond IAnswer
25-Diamond I
September 17, 2024

The behaviour is the same in MC15 and it seems that any loop does the trick

Werner_E_0-1726575440223.png

 

Werner_E_1-1726575470342.png