Janilabo

Janilabo | TSAPos() [SCAR Divi]

Apr 27th, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.88 KB | None | 0 0
  1. {==============================================================================]  
  2.   Explanation: Returns index position of TSA which matched str.
  3.                Returns -1 if any of TSA items doesnt match with str.                  
  4. [==============================================================================}
  5. function TSAPos(TSA: TStrArray; str: string): Integer;
  6. var
  7.   h: Integer;
  8. begin
  9.   h := High(TSA);
  10.   for Result := 0 to h do
  11.     if (TSA[Result] = str) then
  12.       Exit;
  13.   Result := -1;
  14. end;
  15.  
  16. begin
  17.   WriteLn(TSAPos(['a', 'b', 'c', 'd', 'e', 'f', 'g'], '_'));
  18.   WriteLn(TSAPos(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 'a'));
  19.   WriteLn(TSAPos(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 'b'));
  20.   WriteLn(TSAPos(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 'c'));
  21.   WriteLn(TSAPos(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 'd'));
  22.   WriteLn(TSAPos(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 'x'));
  23. end.
Advertisement
Add Comment
Please, Sign In to add comment