Need local variable to close windowI'm trying to generate multiple windows and have the close button close each one separately. However it's not working the way I expected. Try running code 2x; the close button works for one window but not the other one.
::a = "The quick fox jumped over the brown log";
::b = "Hello World I want to get off now";
names default to here(1);
nw = new window("Test",
text box(::a),
text box(::b),
button box("Close", nw << close window)
);


GraphicsScriptingRe: Need local variable to close windowHere is how I would handle it
::a = "The quick fox jumped over the brown log";
::b = "Hello World I want to get off now";
Names Default To Here( 1 );
Eval(
Substitute(
Expr(
__nw__ = New Window( "Test",
Text Box( ::a ),
Text Box( ::b ),
Button Box( "Close", __nw__ << close window )
)
),
Expr( __nw__ ),
Parse( "nw" || Char( Random Integer( 1, 999999999 ) ) )
)
);Re: Need local variable to close windowThanks Jim that works. But two questions:
1. Why does yours work and not mine?
2. It appears that you are assigning __nw__ to a random integer, but it's already "window handle". Doesn't that override it's window handle value?
As a bonus question why all the double underscores? Code works fine without them.
Re: Need local variable to close windowYour code fails, because the second time you run the script, the the "nw" variable is changed to point to the latest window. Basically, the issue is that the "Here" namespace is associated with the script window, not each of the instances run from the script window. My code just creates a new variable every time the code is run.
Concerning the double underscores, it is just a standard I use. I find that it helps in reading and understanding how the code is working.