If every window is independent then I recommend using the window namespace, designed just for this:
Names default to here(1):
// Functions outside the window are still accessible
rand = function({}, floor(random uniform(10)));
win = New Window("Values",
show toolbars(0), show menu(0),
// You can put statements above display elements
window:randomvalue = rand();
v list box(
text box("Enter a value for this box:"),
// All references to display elements should be in the window namespace
window:teb = text edit box(""),
// Examples reading and writing values.
button box("Update random value", window:randomvalue = rand() ),
button box("Get values from this window",
window:tb << Set Text(
"Random value: " || char(window:randomvalue) ||
"\!NEntered Value: " || (window:teb << Get Text)
)
),
window:tb = text box("")
)
);
// You can get to this from outside the window, but make sure this namespace is protected too - for example from inside another window.
show(win:randomvalue, win:teb << Get Text);