int amt;
buffer tosell;
for i from 1 to 4000 {
item it = to_item(i);
if (is_tradeable(it) && stash_amount(it) > 50) {
amt = stash_amount(it)-50;
if (take_stash(amt,it)) {
if (length(tosell) != 0) tosell.append(", ");
tosell.append(amt+" "+to_string(it))...