Based on some further debugging I believe that I understand what is happening.
Updated code:
Names Default To Here( 1 );
EXAMPLE_VALUE = "100";
showExampleModal = Function( {},
{Default Local},
// (1)
hereStr = "Here:EXAMPLE_VALUE: " || Char( Here:EXAMPLE_VALUE );
unqualifiedStr = "EXAMPLE_VALUE: " || Char( EXAMPLE_VALUE );
// (2)
hereStrTextBox = Text Box( "Here:EXAMPLE_VALUE: " || Char( Here:EXAMPLE_VALUE ) );
unqualifiedStrTextBox = Text Box( "EXAMPLE_VALUE: " || Char( EXAMPLE_VALUE ) );
// (3)
Print( hereStr );
Print( unqualifiedStr );
modal = New Window( "Example Modal",
<<Modal,
Border Box( Left( 2 ), Right( 2 ),
V List Box(
// (4)
H Center Box( Text Box( hereStr ) ), // Defined
H Center Box( Text Box( unqualifiedStr ) ), // Defined
H Center Box( Text Box( "Here:EXAMPLE_VALUE: " || Char( Here:EXAMPLE_VALUE ) ) ), // Defined
H Center Box( Text Box( "EXAMPLE_VALUE: " || Char( EXAMPLE_VALUE ) ) ), // Not Defined
H Center Box( hereStrTextBox ), // Defined
H Center Box( unqualifiedStrTextBox ), // Defined
),
),
H List Box(
Spacer Box(),
Button Box( "OK",
// (5)
Print( "On Click" );
Print( "Here:EXAMPLE_VALUE: " || Char( Here:EXAMPLE_VALUE ) ); // Defined
Print( "EXAMPLE_VALUE: " || Char( EXAMPLE_VALUE ) ); // Not defined
)
),
);
);
At (1) the assigments are evaluated right away and so when they are passed later to the Print/Text Box they are defined as I expect. This is confirmed by the output of (3) and the first to Text Boxes of (4).
At (2) the Text Boxes are again evaluated at the time the line is executed, and so when they are displayed, they are again defined using the values that I expect. This is confirmed by the last two Text Boxes of (4)
The middle two Text Boxes of (4) are not in fact evaluated immediately, but passed to the Center Box (or maybe the List Box?) as expressions, and evaluated later/in another scope (I guess the scope of either the List Box or the Center Box). As a result the value of EXAMPLE_VALUE is not what I expected, instead it is the value of EXAMPLE_VALUE in whatever other scope it is being evaluated in (namely it is undefined).
This seems to be confirmed by (5), which also passes the Prints as expressions to be evaluated later / in another scope.
Is this accurate?