Skip to content

FindIndexInListByName

function

Delphi
function FindIndexInListByName (List: string; SearchedString: string; IsSubString: Boolean; IgnoreCase: Boolean): LongInt;
C++Builder
System::LongInt __fastcall FindIndexInListByName(System::UnicodeString List, System::UnicodeString SearchedString, bool IsSubString, bool IgnoreCase);
C#
public int FindIndexInListByName(string List, string SearchedString, bool IsSubString, bool IgnoreCase);
VB.NET
Public Function FindIndexInListByName(List As String, SearchedString As String, IsSubString As Boolean, IgnoreCase As Boolean) As Integer
C++/Qt
int FindIndexInListByName (wchar_t *List, wchar_t *SearchedString, BOOL IsSubString, BOOL IgnoreCase);

Finds the index of an item in a list of strings, searching by the name of the item or by a substring that identifies the item.

E.g., for a given video capture device, the VideoInputs list returns: Composite, SVideo, Tuner. Therefore the index of "Composite" is 0, the index of "SVideo" is 1, and the index of "Tuner" is 2.

To select the "Composite" input programmatically:

procedure TfrmMainForm.Button1Click(Sender: TObject);
var
  i: LongInt;
begin
  i := VideoGrabber.FindIndexInListByName (VideoGrabber.VideoInputs, 'Composite', false, true);
  if i > -1 then begin // if this input exists...
    VideoGrabber.VideoInput := i;
  end;
end;

To select the same input by using only "Compos" as a substring of the input name:

procedure TfrmMainForm.Button1Click(Sender: TObject);
var
  i: LongInt;
begin
  i := VideoGrabber.FindIndexInListByName (VideoGrabber.VideoInputs, 'Compos', true, true);
  if i > -1 then begin // if this input exists...
    VideoGrabber.VideoInput := i;
  end;
end;