Lesson 12 practice 2 scope of text variable changed from while to process one file


This is because the text variable has a While scope, so it’s being kept from iteration to iteration. That means when it is not set with the file text value, because of the Read Text File exception (e.g. 5.txt), then it keeps the previous value (e.g. the 4.txt text).

So when we change the scope to Process one file, variable text is a null value after the append operation? How does it rid itself of the previous value?

I think this might require a technical answer related to try catch blocks but unsure.


I tried the debugger and watched the value of text which still retains the current value until Process one file is closed and the While loop boolean condition executes at which point it is delisted from the table of variables so I think this is something unique to try catch blocks in that this happens.