In this example, the user wishes to locate a particular TRKS bank, with bank number 121. Here, it makes no difference whether an iter-any or an iter-same iterator is used.
TRY_Bank_Key my_key("TRKS",121) ;
TRY_Record_Iter_Any my_iter(p_record, my_key) ;
if (my_iter.is_valid())
{ // Succeeded in locating ("TRKS", 121)
}
Essentially the same code is used if one would prefer to use an iter-same. Here a temporary TRY_Bank_Key variable is used instead. This temporary variable is represented by putting a TRY_Bank_Key constructor directly in the argument list of the TRY_Record_Iter_Same constructor.
TRY_Record_Iter_Same my_iter(p_record, TRY_Bank_Key("TRKS",121)) ;
if (my_iter.is_valid())
{
// Succeeded in locating ("TRKS", 121)
}
Finally, if one just want to find the first TRKS bank, one can write
TRY_Record_Iter_Same my_iter(p_record, "TRKS") ; // match any bank number
if (my_iter.is_valid())
{
// Succeeded in locating the first "TRKS" bank
}