In the.fmsoup recently we discussed an issue raised by @menno. He had seen that local variables declared in one object on a layout were accessible in other areas. His immediate concern was that this was a security issue as it was possible that data would be accessible in places where it should not be seen. I had noticed this problem a while back, and had side-stepped it, without taking time to investigate it much further. With someone else interested, I thought that I would look again at this issue.
I had already bumped into this issue some time ago. I had been experimenting with the use of variables to store strings for field labels and on-screen text. My plan was to find a convenient way to enable language localisation. I was using global variables to trial this and in my early attempts. At the same time, I wondered what would happen if I used local variables or function variables and began experimenting with them too. To my surprise, local variables worked well within a layout. They could even extend to other layouts. That suggested that they could have interesting applications. Unfortunately, there were inconsistencies in behaviour which made them difficult and unreliable. As it was a curiosity experiment, I didn’t take it any further. Now that @menno had raised the issue in the context of a security problem, I thought I would show that there could be something useful in that behaviour too.
My plan was to make a quick demonstration of the use of local variables to allow file-wide replacement of strings from one location. I chose to use button bars as navigation elements and to generate the button labels using local variables. At this point, I am able to say that this can be done. However, it would have to be done skilfully and carefully because the side-effects can cause a wide variety of problems. The following video shows some of those problems. Further experimentation would reveal more about the side effects.
I have generated a quick demonstration video which is only meant to be a discussion document, so please forgive the rough edges.