How about this? It should store every non-bound item in a new array .@ID[]
getinventorylist();
for (.@i = 0; .@i < @inventorylist_count; .@i++) {
/* Filter only items that is not bound */
if (!@inventorylist_bound[.@i]){
.@itemname$ = callfunc( "getitemname2", @inventorylist_id[.@i], @inventorylist_identify[.@i], @inventorylist_refine[.@i], @inventorylist_attribute[.@i], @inventorylist_card1[.@i], @inventorylist_card2[.@i], @inventorylist_card3[.@i], @inventorylist_card4[.@i], @inventorylist_bound[.@i]);
.@menu$ += sprintf("%s %s:", @itemname2_info$, .@itemname$);
.@ID[.@j] = @inventorylist_id[.@i];
.@j++;
}
}
.@menu$ += "Cancel";
.@s = select(.@menu$) -1;
if (.@s == .@j)
close;
/* Now display ItemID of selected inventory */
mesf("You have selected %d", .@ID[.@s]); // this did not return correct info because it reads [.@s] index from getinventorylist but not the filtered menu.