Using Eval(EvalExpr()) or Eval(Substitute()) will let you make runtime variables static. Check the scripting index for examples how to use them.
Names Default to Here( 1 );
RepGen = function({btn_name},
{DEFAULT LOCAL},
print(btn_name);
);
vlb = Vlistbox();
btns = {"Btn 1", "Other", "Button 2 (or3)"};
for(i=1, i<=nitems(btns), i++,
vlb << Append(
Eval(
//run just this block to show that the buttons are getting evaluated at creation time
EvalExpr(
Buttonbox(btns[i], RepGen(Expr(btns[i])))//the expr will evaluate inside the evalexpr
)
)
)
);
new window("Test",
vlb
);