var
  rLoop : real;
  sType : string;
  vTypes : stringvector;

step

  if MenuStart then begin
    RegForm.Set('RFE_LOOP','0');
    System.Action.Trigger (4, 'SHOW');
    GlobalVar.Set('Loop', Val(RegForm.Get('RFE_LOOP'),1));
    ClearMenuStart;
  end;

  rLoop := GlobalVar.Get('Loop', 0);
  if rLoop > 0 then begin

    TypeList.First;
    while not TypeList.EOF do begin
      if Pos(RegForm.Get('RFE_TYPE'), TypeList.TypeFamily) > 0 then begin
        vTypes := vTypes + [TypeList.TypeCode];
      end;
      TypeList.Next;
    end;

    if Len(vTypes) > 0 then begin
      sType := vTypes[Math.Random(Len(vTypes) - 1) + 1];

      SetTypeCode(sType);

      SetBarcode(sType + '_' + HexStr( Math.Random(100), 4));
      StartTest;

      GlobalVar.Set('Loop', rLoop - 1);
    end else begin
      GlobalVar.Set('Loop', 0);
    end;

  end;

end.
