Skip to content

FindIndexInListByName

method

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 a substring that identifies the item.

E.g., for a given video capture device, the VideoInputs list returns:

CompositeSVideoTuner Therefore the index of "Composite" is 0, the index of "SVideo" in 1, and the index of "Tuner" is 2.

E.g. to programmatically select the "Composite" input, proceed as follows:

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;

Or to select the same input by using only "Compos" as 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;