# Avoid repeatability issue of "For" after saving a file?

Posted 10 months ago
735 Views
|
4 Replies
|
0 Total Likes
|
 Dear Friends,Attached *.nb file contains a code for a loop problem, and output is as expected. My problem is that when I am running the code again after saving the file ( or running again after deleting o/p & quitting kernel), it gets stuck in the first step of For loop. It is quite annoying as successfully running the code once means my code is fine, but then it fails for some unknown reason. Will be thankful for any suggestion. Thanks
4 Replies
Sort By:
Posted 10 months ago
 Sorry, I cannot reproduce the problem. The output is the same every time I run the code, after saving.
Posted 10 months ago
 Please find the attached file, it has the o/p which I am getting after rerunning the code. Pl see the last o/p Thanks
 The first time you run the code, the global variable m has no value. At the end of the loop, m has the value 6. If you rerun the code, the command SEM[m - 1] - SEM[m] behaves differently than before. If that is a problem for you, just add Clear[m,k] at the start of the code.