thanks for that - sometime i get caught up in what i am doing and cant think of easy answer

here is simulated code ill try,my real codes has multi indexed variables ,but the principle is correct
the end value shown needs to be the lowest number between 1 -6 for my use , 0 is ok as it show there is no " index slots" Left and is used to determine if more index slots are added later

Code:
z = 0
X = 0
index_slot = 0 
 
for z = 0 the index                                 ' test to array length 
    if value1(z) & $F0 = value2 then           ' match upper nibble 
      for X = 1 to 6
           Y  = value1(z) & $0F                   ' get lower nibble value into Y
           if  X = Y  then Index_slot.X = 1     ' put a 1 into the bit location representing values 1- 6 of index_slot that have been used    
      next X
 next z
 
x = 0 
 for X = 6 to 1                                            
    if index_slot.X >> X = 1  then index_slot = X  '  show the lowest value available  index slot for use 
 next X