Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {==============================================================================]
- Explanation: Returns index position of TSA which matched str.
- Returns -1 if any of TSA items doesnt match with str.
- [==============================================================================}
- function TSAPos(TSA: TStrArray; str: string): Integer;
- var
- h: Integer;
- begin
- h := High(TSA);
- for Result := 0 to h do
- if (TSA[Result] = str) then
- Exit;
- Result := -1;
- end;
- begin
- WriteLn(TSAPos(['a', 'b', 'c', 'd', 'e', 'f', 'g'], '_'));
- WriteLn(TSAPos(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 'a'));
- WriteLn(TSAPos(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 'b'));
- WriteLn(TSAPos(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 'c'));
- WriteLn(TSAPos(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 'd'));
- WriteLn(TSAPos(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 'x'));
- end.
Advertisement
Add Comment
Please, Sign In to add comment