Suppose this code:
1. #pragma verboselevel 9
2. #define i 0
3.
4. #redim MyArray[1]
5. #define MyArray[0] = "Value 0"
6. #sub SubA
7. #define Item MyArray[i]
8. ; Do something with {#Item}
9. #endsub
10. #for { i = 0; i < DimOf(MyArray); i++ } SubA
11.
12. #redim MyArray[2]
13. #define MyArray[0] "Value 1"
14. #define MyArray[1] "Value 2"
15. #sub SubB
16. ; Next line returns error: "Index 1 is out of array MyArray size"
17. #define Item MyArray[i]
18. ; Do something with {#Item}
19. #endsub
20. #for { i = 0; i < DimOf(MyArray); i++ } SubB
When ISPP gets to the #define Item assignment in #sub SubB, it gives the error "Index 1 is out of array MyArray size."
The debug output:
Line 1: Changed level of verbosity: 9
Line 2: Public variable defined: i
Line 4: Public array declared: MyArray
Line 5: Public variable defined: MyArray
Line 10: Private array declared: LOCAL
Line 7: Private variable defined: Item
Line 12: Private array declared: MyArray
Line 13: Private variable defined: MyArray
Line 14: Private variable defined: MyArray
Line 20: Private array declared: LOCAL
Line 17: Private variable defined: Item
Line 18: Private array declared: LOCAL
***Compile aborted.
Interestingly, it looks like identifier visibility changes after the first #sub from public to private.
To work around this, I can declare #define protected at the top of the script and then repeat this after each sub where I reuse the array.
Am I am missing something in the docs about the identifier visibility change after the first #sub declaration?