Here is a piece of code that works:
nr=5;
new window("Button test",
Lineuplist=Lineup Box( N Col( 2 ),
)
);
For(i=1,i<=nr,i++,
Lineuplist << append(textbox("Text nr "||char(i)));
Lineuplist << append(
buttonbox("Button nr "||char(i),
<< Set Function(
Function({this},
ps=this<<sib;
par=this<<parent;
buttonName=this<<get button name;
buttonNo=regex(buttonName,".*?([0-9]*)$","\1");
locator=eval insert("//TextBox[text()='Text nr ^buttonNo^']");
textBox=par<<xpath(locator);
textBox<<delete;
this<<delete;
)
)
);
);
);