Just wanted to add something about this, since it’s a subtle issue that can produce extremely aggravating bugs.
The issue here is using the word “let” to change the name of a global variable. When you use “let” it creates a temporary variable–even if there’s already a global variable with the same name! As nicely demonstrated here.
The way to avoid this: Always change global variables by saying “Now the played code is…” rather than “Let the played code be…” Only use “let” for temporary variables. Probably it’s good practice to only use “let” when creating a new temporary variable, since you can change existing ones with “now.”
(§11.15 of Writing with Inform discusses Let and temporary variables, though I think it sort of suggests that you can’t use “let” with variable names that are already in use, which is not true–you can do this, it’ll just create this bug!)